如何用VB制作手机?

时间:2013-04-19 01:58:37

标签: visual-studio

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

我到目前为止。

  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

1 个答案:

答案 0 :(得分:0)

<强>线索信息

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

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

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

 myString.Contains("#")