Results 1 to 8 of 8

Thread: VB Expert pls help ME T_T

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2013
    Posts
    2

    Unhappy 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

  2. #2
    Frenzied Member
    Join Date
    May 2006
    Location
    some place in the cloud
    Posts
    1,886

    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 ...

  3. #3
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: VB Expert pls help ME T_T

    vb Code:
    1. Private Sub btnDial_Click(sender As Object, e As System.EventArgs) Handles btnDial.Click
    2.         If lblInput.Text.Contains("*") OrElse lblInput.Text.Contains("#") Then
    3.             MessageBox.Show("Please enter a number", "Error", MessageBoxButtons.OK)
    4.         Else
    5.             lblInput.Text = "DIALING..."
    6.         End If
    7. End Sub



  4. #4
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: VB Expert pls help ME T_T

    Moved to the VB.Net forum.

    Quote Originally Posted by jggtz View Post
    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.

  5. #5
    Frenzied Member zuperman's Avatar
    Join Date
    Dec 2000
    Location
    Portugal
    Posts
    1,033

    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
    Help keep this forum clean: Remember to mark your thread as resolved · Search before you post · Remember to rate posts that help

    VS2010: Visual Studio 2010 Keybinding Posters
    · Service Pack 1
    Tools: GhostDoc - automatically generates XML documentation comments
    · NuGet package Manager · PowerCommands IDE extensions
    Source Control: ankhsvn - integration for SVN
    · Windows Shell Extension for Subversion

    Development Laptop: Intel Core i5 430M 2.26 GHz @ 2.53 GHz
    · 4096 MB, DDR3 PC3-8500F (533 MHz), Kingston · ATI Mobility Radeon HD 5470 · 15.6 @ 16:9, 1366x768 pixel, HD LED LCD

    I follow:
    JoelOnSoftware - A weblog by Joel Spolsky, a programmer working in New York City, about software and software companies
    ScottGu's Blog - Scott Guthrie works for Microsoft as the Product Manager of the .NET Framework
    Portugal-a-Programar - Portuguese Developers Community
    .NET Rocks! - is a weekly Internet audio talk show for .NET Developers.

    Programming Languages:
    C#
    · VB.NET · JAVA · PHP · Javascript
    Other:
    XML
    · HTML · CSS · JQuery · SQL



    *** Proudly Portuguese ***

  6. #6
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    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.

  7. #7
    Frenzied Member zuperman's Avatar
    Join Date
    Dec 2000
    Location
    Portugal
    Posts
    1,033

    Re: VB Expert pls help ME T_T

    good point, sir...
    Help keep this forum clean: Remember to mark your thread as resolved · Search before you post · Remember to rate posts that help

    VS2010: Visual Studio 2010 Keybinding Posters
    · Service Pack 1
    Tools: GhostDoc - automatically generates XML documentation comments
    · NuGet package Manager · PowerCommands IDE extensions
    Source Control: ankhsvn - integration for SVN
    · Windows Shell Extension for Subversion

    Development Laptop: Intel Core i5 430M 2.26 GHz @ 2.53 GHz
    · 4096 MB, DDR3 PC3-8500F (533 MHz), Kingston · ATI Mobility Radeon HD 5470 · 15.6 @ 16:9, 1366x768 pixel, HD LED LCD

    I follow:
    JoelOnSoftware - A weblog by Joel Spolsky, a programmer working in New York City, about software and software companies
    ScottGu's Blog - Scott Guthrie works for Microsoft as the Product Manager of the .NET Framework
    Portugal-a-Programar - Portuguese Developers Community
    .NET Rocks! - is a weekly Internet audio talk show for .NET Developers.

    Programming Languages:
    C#
    · VB.NET · JAVA · PHP · Javascript
    Other:
    XML
    · HTML · CSS · JQuery · SQL



    *** Proudly Portuguese ***

  8. #8
    Frenzied Member
    Join Date
    May 2006
    Location
    some place in the cloud
    Posts
    1,886

    Re: VB Expert pls help ME T_T

    Quote Originally Posted by Joacim Andersson View Post
    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
  •  



Click Here to Expand Forum to Full Width