I’m working in Visual Basic .NET, and I’m trying to get split to work.
Here is my code:
Public Sub CheckUpdate(ByVal FileURL As String)
Dim instance As WebClient = New WebClient
Dim ApplyTo As String = instance.DownloadString(FileURL)
asd = ApplyTo.Split(",")
End Sub
I use it like this:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
NewUpdate.CheckUpdate("version.txt")
Label1.Text = NewUpdate.asd(0)
End Sub
(Yeah, I know I use it on a local .txt file for now!)
So with asd(0) it reads the whole file. If I check asd(1) I get IndexOutOfRange. So how does Split() work?
String.Split returns an array with all the parts of the string separated by the specified character (in your case it’s a comma). If asd(1) is out of range, that means you don’t have any comma in your string.
Consider the following code: