请帮我找出这段代码中的错误。我花了一个多小时寻找它。这是代码..
Public Class Form1
Dim incomingip() As String
Dim incomingopt() As String
Private Sub btnloadall_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnloadall.Click
Timer1.Start()
rtb.Clear()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
ProgressBar1.Increment(5)
If ProgressBar1.Value = 10 Then
sPort.Write("get ip" & vbCr)
End If
If ProgressBar1.Value = 20 Then
Call btnip_Click(sender, New System.EventArgs)
End If
If ProgressBar1.Value = 30 Then
rtb.Clear()
End If
If ProgressBar1.Value = 40 Then
sPort.Write("get opt" & vbCr)
End If
If ProgressBar1.Value = 50 Then
Call btnopt_Click(sender, New System.EventArgs)
End If
'If ProgressBar1.Value = 40 Then
' rtb.Clear()
'End If
If ProgressBar1.Value = ProgressBar1.Maximum Then
Timer1.Stop()
End If
End Sub
在这里,每次我在 rtb 中写东西时,我总是将其清除,因此变量不会读取出现的第一个变量。
Private Sub btnip_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnip.Click
incomingip = stringOfRtb.Split(ControlChars.CrLf.ToCharArray) ''vcrlf splitter
''ip parameters
ip = incomingip(2).Split("="c)
txtIP.Text = ip(1)
ip = incomingip(3).Split("="c)
txtMask.Text = ip(1)
ip = incomingip(5).Split("="c)
txtHost.Text = ip(1)
ip = incomingip(4).Split("="c)
txtDfg.Text = ip(1)
ip = incomingip(10).Split("="c)
txtBackupIP.Text = ip(1)
ip = incomingip(1).Split("="c)
cboDhcp.Text = ip(1)
End Sub
它现在可以很好地显示从 rtb 到不同文本框的拆分字符串..
Private Sub btnopt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnopt.Click
incomingopt = stringOfRtb.Split(ControlChars.CrLf.ToCharArray) ''vcrlf splitter
opt = incomingopt(0).Split("="c)
txtJointimer.Text = opt(1)
opt = incomingopt(1).Split("="c)
txtReplace.Text = opt(1)
opt = incomingopt(2).Split("="c)
txtDeviceID.Text = opt(1)
opt = incomingopt(3).Split("="c)
txtPassword.Text = opt(1)
opt = incomingopt(4).Split("="c)
txtFormat.Text = opt(1)
opt = incomingopt(5).Split("="c)
txtSignal.Text = opt(1)
opt = incomingopt(6).Split("="c)
txtAverage.Text = opt(1)
End Sub
这个事件显示相同的字符串!即使我声明了不同的实例,此事件也会从 btnip 获取字符串。这不是我想从中得到的。就像我在这里使用了incomingip。我没有看到什么吗?