Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Visual Basic

Options
  • 12-03-2005 7:58pm
    #1
    Registered Users Posts: 542 ✭✭✭


    Hey,

    i have a programme that takes in details from the user and stores them in a data base. what i want to do is when i read in the data entered in the text box, i want to validate it. for example, in the FirstName textbox, i want to make sure numbers cannot be entered. Any help is much appreciated!!

    Dee


Comments

  • Registered Users Posts: 542 ✭✭✭Hoochiemama


    also, would anyone know a way to validate the number of characters ina textbox,

    e.g. - student ID text box must be 8 digits long


  • Registered Users Posts: 2,497 ✭✭✭optiplexgx270


    in the function fot the button click or whatever do an if textbox.length <8 display a label and return


  • Registered Users Posts: 542 ✭✭✭Hoochiemama


    .length isn't recognised by VB


  • Moderators, Politics Moderators Posts: 39,765 Mod ✭✭✭✭Seth Brundle


    within your checking procedure...
    'check that it is 8 chars long
    If Len(txtFirstname.Text) <> 8 Then MsgBox ("must have 8 chars!")
    
    'check no numbers
    For i = 0 To 9
       If InStr(txtFirstname.Text, i) Then MsgBox ("No numbers allowed!")
    Next
    


  • Registered Users Posts: 2,497 ✭✭✭optiplexgx270


    my visual studio 2003 wouldnt open and i wasnt going to hand you the code but well there it is above


  • Advertisement
  • Registered Users Posts: 542 ✭✭✭Hoochiemama


    thanks a million!! my hair thanks you cos i was about to start pulling it out!! :D


  • Registered Users Posts: 2,781 ✭✭✭amen


    you should really look at the keypress function this allows you to check the value in your input box as it is entered and determine if its a char/number etc and stop the entry if it is not of the required format.
    While kbannons is functionaly correct its not the best or fastest way to process

    As for the 8 characters a text box in vb has a max lenght property
    you can set this to 8

    you could also check the 8 character in the keypress function


  • Registered Users Posts: 2,497 ✭✭✭optiplexgx270


    i did think there was a max length prop but as i said my visual studio 2003 wouldnt open so i couldnt be sure


Advertisement