|
-
Apr 18th, 2013, 09:04 PM
#1
Thread Starter
New Member
VB Expert pls help ME T_T
So, I'm trying to make a phone...... It should has 14 buttons(0-9,*,#, "Dial", "End" ) and a label(the answer). If all you clicked were number, then when u click dial, the label should show you this message "DIALING...", if however there's * or #, then a message will pop up "Please enter a number" when you click dial.
I got this far.... Please help me T_T
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
End Class
-
Apr 19th, 2013, 12:34 AM
#2
Re: VB Expert pls help ME T_T
You should post in VB.Net forum
JG
... If your problem is fixed don't forget to mark your threads as resolved using the Thread Tools menu ...
-
Apr 19th, 2013, 01:04 AM
#3
Re: VB Expert pls help ME T_T
vb Code:
Private Sub btnDial_Click(sender As Object, e As System.EventArgs) Handles btnDial.Click If lblInput.Text.Contains("*") OrElse lblInput.Text.Contains("#") Then MessageBox.Show("Please enter a number", "Error", MessageBoxButtons.OK) Else lblInput.Text = "DIALING..." End If End Sub
-
Apr 19th, 2013, 03:55 AM
#4
Re: VB Expert pls help ME T_T
Moved to the VB.Net forum.
 Originally Posted by jggtz
You should post in VB.Net forum
No! Don't encourage people to create duplicate threads in multiple forums. If a thread is created in the wrong forum, report the post and one of us moderators will move it. Which is just what I've now done.
-
Apr 19th, 2013, 05:12 AM
#5
Frenzied Member
Re: VB Expert pls help ME T_T
Just a side note:
You could try to implement Control Arrays, like we use to do in VB6
http://msdn.microsoft.com/en-us/libr...=vs.71%29.aspx
One click event handler for all the buttons... that way the size of your code will be reduced
-
Apr 19th, 2013, 05:28 AM
#6
Re: VB Expert pls help ME T_T
You don't need control arrays in VB.Net to have the same event handler for more than one control:
Code:
Private Sub Button_Click(sender As Object, e As System.EventArgs) Handles btn1.Click, btn2.Click, btn3.Click
lblInput.Text &= CType(sender, Button).Text
End Sub
Last edited by Joacim Andersson; Apr 19th, 2013 at 05:32 AM.
-
Apr 19th, 2013, 06:28 AM
#7
Frenzied Member
Re: VB Expert pls help ME T_T
-
Apr 19th, 2013, 11:05 AM
#8
Re: VB Expert pls help ME T_T
 Originally Posted by Joacim Andersson
Moved to the VB.Net forum.
No! Don't encourage people to create duplicate threads in multiple forums. If a thread is created in the wrong forum, report the post and one of us moderators will move it. Which is just what I've now done.
Received... and already learned how to report a post...
JG
... If your problem is fixed don't forget to mark your threads as resolved using the Thread Tools menu ...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|