我是VSB编程的新手,似乎无法解决这个问题。
我有一个基本程序,可以连接和断开用户飞机。现在,如果你输入呼号" VIR12E"进入文本框并点击" Connect"按钮,"连接"文字变成"断开"。
我现在要做的是让断开连接按钮工作,当你点击"断开"按钮,文本变回"连接"。
这是我的代码:
Public Class Form1
Private Sub Connect_Click(sender As Object, e As EventArgs) Handles Connect.Click
If textBoxMessage.Text = "VIR12E" Then
Connect.Text = "Disconnected"
ElseIf trim(textBoxMessage.Text & vbnullstring) = vbnullstring Then
Connect.Text = "Connect"
Instructions.Visible = True
End If
End Sub
Private Sub Connect_Click(sender As Object, e As EventArgs) Handles Connect.Click
Connect.Text = "Connect"
End Sub
End Class
我收到以下错误:
'Private Sub Connect_Click(sender As Object, e As EventArgs)' has multiple definitions with identical signatures.
答案 0 :(得分:0)
Private Sub Connect_Click(sender As Object, e As EventArgs) Handles Connect.Click
If Connect.Text = "Connect" Then
If textBoxMessage.Text = "VIR12E" Then
Connect.Text = "Disconnect"
End If
Else
'Put your disconnect logic here (empty the textbox, show instructions or something)
Connect.Text = "Connect"
End If
End Sub
并删除其他Connect_Click定义。这种If结构可以简化,但我想你会有更多的逻辑。