Public URLs As String()
Public Sub LoadData()
Dim LineIn As String, CIndex As Integer
LineIn = Nothing : CIndex = 0
Microsoft.VisualBasic.FileOpen(1, "Data\URLS.WWD", OpenMode.Input, OpenAccess.Read)
While Not EOF(1)
LineIn = Microsoft.VisualBasic.FileSystem.LineInput(1)
If InStr(LineIn, "URL=", CompareMethod.Text) = 1 Then
URLs(CIndex) = Mid(LineIn, 5, LineIn.Length - 4)
End If
CIndex = CIndex + 1
End While
Microsoft.VisualBasic.FileClose(1)
End Sub
MSVS 8, VB "NullReferenceException"
Ok, I know that I am supposed to set my variables to new values, but I have been working on this for hours trying to get it to allow me to set my value for the string. I am used to VB 6 and the migration to the 2005 edition has been fine so far until this. Here's my code:
Now, the error is on the line URLs(CIndex) = Mid(LineIn, 5, LineIn.Length - 4). Why after all this time can't I get it to work? I even followed the MSDN directions here. Help?
Oops.
Add
just before the line where you get the error.
You might also want to move the increment of CIndex inside the if statement. Otherwise, you will have some blank elements in your resulting array for lines that did not have "URL=" in them.
Add
ReDim Preserve URLs(CIndex)
just before the line where you get the error.
You might also want to move the increment of CIndex inside the if statement. Otherwise, you will have some blank elements in your resulting array for lines that did not have "URL=" in them.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement