-4

我正在尝试制作电话。它应该有 14 个按钮(0-9、*、#、“拨号”、“结束”)和一个标签(答案)。如果你点击的都是号码,那么当你点击拨号时,标签应该会显示这个消息“DIALING...”。如果有*或#,则点击拨号时会弹出“请输入号码”的信息。

我走到这一步了。

  Private Sub btn0_Click(sender As System.Object, e As System.EventArgs) Handles btn0.Click
    Const int0 As Integer = 0
    lblinput.Text &= int0
End Sub

Private Sub btn1_Click(sender As Object, e As System.EventArgs) Handles btn1.Click
    Const int1 As Integer = 1
    lblinput.Text &= int1
End Sub

Private Sub btn2_Click(sender As Object, e As System.EventArgs) Handles btn2.Click
    Const int2 As Integer = 2
    lblinput.Text &= int2
End Sub

Private Sub btn3_Click(sender As Object, e As System.EventArgs) Handles btn3.Click
    Const int3 As Integer = 3
    lblinput.Text &= int3
End Sub

Private Sub btn4_Click(sender As Object, e As System.EventArgs) Handles btn4.Click
    Const int4 As Integer = 4
    lblinput.Text &= int4
End Sub

Private Sub btn5_Click(sender As Object, e As System.EventArgs) Handles btn5.Click
    Const int5 As Integer = 5
    lblinput.Text &= int5
End Sub

Private Sub btn6_Click(sender As Object, e As System.EventArgs) Handles btn6.Click
    Const int6 As Integer = 6
    lblinput.Text &= int6
End Sub

Private Sub btn7_Click(sender As Object, e As System.EventArgs) Handles btn7.Click
    Const int7 As Integer = 7
    lblinput.Text &= int7
End Sub

Private Sub btn8_Click(sender As Object, e As System.EventArgs) Handles btn8.Click
    Const int8 As Integer = 8
    lblinput.Text &= int8
End Sub

Private Sub btn9_Click(sender As Object, e As System.EventArgs) Handles btn9.Click
    Const int9 As Integer = 9
    lblinput.Text &= int9
End Sub

Private Sub btn10_Click(sender As Object, e As System.EventArgs) Handles btn10.Click
    Dim str10 As String = btn10.Text
    lblinput.Text &= str10
End Sub

Private Sub btn11_Click(sender As System.Object, e As System.EventArgs) Handles btn11.Click
    Dim str11 As String = btn11.Text
    lblinput.Text &= str11

End Sub

Private Sub btnEnd_Click(sender As System.Object, e As System.EventArgs) Handles btnEnd.Click
    Me.Close()
End Sub
Private Sub btnDial_Click(sender As Object, e As System.EventArgs) Handles btnDial.Click

End Sub
4

1 回答 1

0

线索

要测试输入是否为所有数字,您可以使用正则表达式:

 Regex.IsMatch(lblinput.Text, "^[0-9]+$")

要测试它是否包含某些内容,您可以使用字符串的 Contain 方法:

 myString.Contains("#")
于 2013-04-19T02:22:41.090 回答