Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Visual Basic

  • 12-03-2005 07:58PM
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 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, Registered Users 2 Posts: 2,587 ✭✭✭optiplexgx270


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


  • Registered Users, Registered Users 2 Posts: 542 ✭✭✭Hoochiemama


    .length isn't recognised by VB


  • Moderators, Politics Moderators, Paid Member Posts: 44,044 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, Registered Users 2 Posts: 2,587 ✭✭✭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, Registered Users 2 Posts: 542 ✭✭✭Hoochiemama


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


  • Registered Users, Registered Users 2 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, Registered Users 2 Posts: 2,587 ✭✭✭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