【发布时间】:2023-04-10 12:21:02
【问题描述】:
这个程序加载一个 .txt 文件,用 ":" 分割它,然后取出每个文件并在某处检查它们 每当我的程序到达列表末尾时出现错误这是我的代码
Private Sub Button5_Click(sender As System.Object, e As System.EventArgs) Handles Button5.Click
If ListBox1.Items.Count = 0 Then
MsgBox("Checking DONE")
ElseIf ListBox1.Items.Count.ToString > 0 Then
Dim str As String
Dim strArr() As String
str = ListBox1.Items(0)
strArr = str.Split(":")
If str.Count > 0 Then
WebBrowser1.Document.GetElementById("email").SetAttribute("value", (strArr(0)))
WebBrowser1.Document.GetElementById("password").SetAttribute("value", (strArr(1)))
WebBrowser1.Document.GetElementById("login-form-contBtn").InvokeMember("click")
WaitForPageLoad()
Threading.Thread.Sleep(5000)
Me.Button2.PerformClick()
Else
MsgBox("Done")
End If
End If
End Sub
Me.Button2.PerformClick() 也以编程方式单击按钮,然后按两个按钮单击此按钮,它应该继续直到列表框为空,但它只是崩溃/给出the error
这是将列表导入列表框的按钮
OpenFileDialog1.InitialDirectory = "./"
OpenFileDialog1.FileName = "Open a text file..."
OpenFileDialog1.Filter = "Text Files (*.txt) | *.txt"
OpenFileDialog1.ShowDialog()
Dim R As New IO.StreamReader(OpenFileDialog1.FileName)
Dim string1 As String() = R.ReadToEnd().Split(New String(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries))
ListBox1.Items.AddRange(string1)
R.Close()
ListBox1.SelectedItem = ListBox1.Items(0)
Dim str As String
Dim strArr() As String
str = ListBox1.SelectedItem
strArr = str.Split(":") 'Delimits the imported combo list
Label4.Text = (strArr(0)) 'Email
Label3.Text = (strArr(1)) 'Password
Label6.Text = (ListBox1.Items.Count) 'How big is combo?
【问题讨论】:
标签: arrays vb.net visual-studio-2010 indexing