Привет, я новичок в VB и в процессе обучения. Эта ошибка иногда возникает, а иногда не возникает, что мне кажется странным. Я получаю сообщение об ошибке Index was outside the bounds of the array, которое указывает на Button30.Text = Split(newestversion, vbCrLf)(**1**)
Мой мотив состоит в том, чтобы читать строку за строкой из текстового файла, размещенного в Интернете. Например,
label1.text = line 1 of the text file
label2.text = line 2 of the text file
Это очень то, чего я хочу.
Вот мой текущий код (ОТРЕДАКТИРОВАНО):
Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("direct link to my online txt file")
Dim response As System.Net.HttpWebResponse = request.GetResponse
Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream)
Dim stringReader As String
stringReader = sr.ReadLine()
Button10.Text = stringReader
Dim newestversion As String = sr.ReadToEnd
Dim currentversion As String = Application.ProductVersion
Dim part() As String = Split(newestversion, vbCrLf)
If part.Length < 10 Then
' not enough items in the array. You could also throw and exception or do some other stuff here
Label10.Text = "beta"
Exit Sub
End If
'updates new episode numbers on buttons
Button20.Text = part(0)
Button30.Text = part(1)
Button40.Text = part(2)
Button50.Text = part(3)
Button60.Text = part(4)
Button70.Text = part(5)
Button80.Text = part(6)
Button90.Text = part(7)
Button100.Text = part(8)
Button110.Text = part(9)
End If
Благодарю вас!!
newestversionсостоит из недостаточного количества строк. - person WeSt   schedule 18.02.2015