Results 1 to 6 of 6

Thread: [RESOLVED] phone keypad - strings

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2006
    Location
    Sheffield
    Posts
    10

    Resolved [RESOLVED] phone keypad - strings

    hi,
    basically i'm making a very simply phone keypad in VB.
    first things first: would the display work better as a label or text box?
    second: how can i make it so when i press a number it appears in the textbox/label?
    and third: i need the numbers to stay in the textbox/label such as, if i click the "1" button, a one appears, and then when i click the "2" button the display now reads "12" instead of deleting the one and replacing it with a 2! How?

    i know this is basic stuff but it's my first time using VB and i'm hopelessly lost.

    thanks.
    x.

  2. #2
    Fanatic Member drpcken's Avatar
    Join Date
    Apr 2004
    Location
    devenv
    Posts
    591

    Re: phone keypad - strings

    I would use a textbox (named TextBoxDisplay in this example), so the user could edit the number. If this is what you want.

    Create buttons for each number on the keypad and on each buttons click handler event add

    VB Code:
    1. 'For Button number 1
    2.  
    3. Private Sub btnNum1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNum1.Click
    4.  
    5.      TextBoxDisplay.Text += "1"  'the += tells it to add the number to the current value already in the TextBox
    6.  
    7. End Sub
    8.  
    9. 'same for button 2
    10. Private Sub btnNum2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNum2.Click
    11.  
    12.      TextBoxDisplay.Text += "2"
    13.  
    14. End Sub

    And so on...
    Good luck!

    In the unlikely event that I answer your question correctly, please Rate my post

    Using Visual Studio 2005 Professional

  3. #3
    Hyperactive Member Bearnerd's Avatar
    Join Date
    Apr 2006
    Location
    Malaysia
    Posts
    290

    Re: phone keypad - strings

    Both label and textbox will work better to display the resulting number. It depends on how you customize the property of the textbox/label. Cheese

  4. #4
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,692

    Re: phone keypad - strings

    1) A Label is a TextBox that a) the user can't write in and b) defaults to flat and no border. Otherwise they're pretty much the same control. If you don't want the user to be able to type directly into the display without your doing anything to prevent it, use a label. You can set it to FixedSingle Border Style and White Background and it'll look the same as a TextBox.

    2 & 3) In the number 1's click event (cmdButton1_Click)
    VB Code:
    1. Label1.Caption = Label1.Caption & "1"
    Do that for each button's _Click event, changing the "1" to the number of the button.

  5. #5

    Thread Starter
    New Member
    Join Date
    Mar 2006
    Location
    Sheffield
    Posts
    10

    Re: phone keypad - strings

    Thankyou all,
    i tried the suggestions and Al42's worked just fine !
    thankyou very much!
    x.

  6. #6
    Fanatic Member drpcken's Avatar
    Join Date
    Apr 2004
    Location
    devenv
    Posts
    591

    Re: phone keypad - strings

    Congrats and good work!
    Don't forget to use the thread tools to Resolve the thread

    In the unlikely event that I answer your question correctly, please Rate my post

    Using Visual Studio 2005 Professional

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