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

how can i get the value ina textbox in vb

Options
  • 01-04-2006 4:53pm
    #1
    Registered Users Posts: 221 ✭✭


    ...and check that it's of a certain data type. sorry i know this is simple but i've looked it up and i keeping getting directed to dirived classes and stuff

    all help is great thanks

    -Elfman


Comments

  • Moderators, Society & Culture Moderators Posts: 9,689 Mod ✭✭✭✭stevenmu


    A textbox's value will always be a string. If you mean you want to check if that string contains an integer, decimal etc then there's a couple of things you can do. The "proper" way of doing it is probably to use regular expressions and check if the text matches whatever pattern you need. You could also just try and convert it to whatever type you expect it to be, making sure to trap the error if it fails. If you're using VB.Net some of the standard types have a tryparse function that'll check that for you, for eg Integer.TryParse(textbox1.text) will return true if it can convert to an integer, false if not. Not sure if theres an equivelent for earlier VB versions.


Advertisement