Results 1 to 9 of 9

Thread: Pop up box ?

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2004
    Posts
    7

    Pop up box ?

    Hello People,

    i have a text box which only allows 2 digits to be entred, is there any way i can have a message box show if the user tries to enter 3 numbers?

    or put some code on my button which checks to see if there is a value in the text box, at the moment if i click the enter button it crahses my programe, i would like it to say u have to enter a value first, so this cannot happen

    Thank you people!!!


  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Put this code in the change Event of the textbox

    VB Code:
    1. If textbox1.text.length > 2 then
    2. messagebox.show("you're not allowed to enter more than 2 digits")
    3. end if

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2004
    Posts
    7

    Thumbs up

    Thanks thats working great now, also could i limit the field size so only numbers 1 to 49 can be inputted?

    do u know how i could validate the button cos at the moment if the user clicks the enter button without putting any data into the text boxes it crashes my programe?

    Thanks


  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    In the keypress event , paste this code .
    VB Code:
    1. Dim KeyAscii As Integer
    2. KeyAscii = Asc(e.KeyChar)
    3. 'only allow numbers, a single decimal point, backspace or enter
    4.  
    5. Select Case KeyAscii
    6. Case Asc("0") To Asc("9"), Asc(ControlChars.Back)
    7. 'acceptable keys
    8. e.Handled = False
    9.  
    10. Case Asc(ControlChars.Cr)
    11. 'enter key - move to next box
    12. txtInterest.Focus()
    13. e.Handled = False
    14.  
    15. Case Asc(".")
    16. 'check for existance of decimal point
    17. If InStr(txtDeposit.Text, ".") = 0 Then
    18. e.Handled = False
    19. Else
    20. e.Handled = True
    21. End If
    22. Case Else
    23. e.Handled = True
    24. End Select

  5. #5

    Thread Starter
    New Member
    Join Date
    May 2004
    Posts
    7
    thanks i get this error back now

    'Handled' is not a member of 'System.EventArgs'.

    ??

  6. #6
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by TheOneWhoLearns
    thanks i get this error back now

    'Handled' is not a member of 'System.EventArgs'.

    ??
    Where did you put this code ?

  7. #7

    Thread Starter
    New Member
    Join Date
    May 2004
    Posts
    7
    Yeah got that working now, if i click the button now without any entries in the text boxes then it doesn't crash the programe, although if i put one entry into the textbox and then leave the others empty and click it, it still crashes!

    Is there any way i can do this so that, it only performs its fucnction once all the textboxes have data in them, and if not it puts a pop up saying you must fill in all the text boxes?


    Thank You!



  8. #8
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682
    Lose that message box about not entering 3 digits and just set the textbox's MaxLength property to 2.

    Then you can query the number without worrying about the length of the data.
    I don't live here any more.

  9. #9

    Thread Starter
    New Member
    Join Date
    May 2004
    Posts
    7
    Originally posted by wossname
    Lose that message box about not entering 3 digits and just set the textbox's MaxLength property to 2.

    Then you can query the number without worrying about the length of the data.
    ive done that now but how do i query the data?

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