NetPochi

Hello. A question please. In a version of VB that I don't remember exactly, a textbox had a property called "numeric" which avoids characters. In VB2005 is there something like this

Thanks...



Re: Visual Basic Language Validating Textbox

jwooley

With winforms you can use either a MaskedTextBox or a NumericUpDown control depending on your needs.

Jim Wooley
http://devauthority.com/blogs/jwooley






Re: Visual Basic Language Validating Textbox

Tailor

Hi,

The MaskedTextBox control is great for controlling input of data, in that you can really format the way data is entered. Not only can you limit it to numeric, and/or alpha characters, you can control Case and what characters go in each place in the textbox.

e.g >LLL0000L will only accept three letters (which are forced to upper case) followed by four numbers, followed by one uppercase letter.

Its possible by changing the format of the mask to permit either numbers or letters in any position, and also possible to include other literal characters like ( ) etc as placeholders. eg (999)-000-0000 will accept a US telephone number where the area code is optional. Change the 999 to 000 and the area code becomes mandatory.

If you are writing the data back to a database, be aware to set the prompt character correctly in the properties, otherwise it will be saved in any spaces of the mask which do not have to have data entered.

HTH

Tailor





Re: Visual Basic Language Validating Textbox

NetPochi

Thanks. Suppose I use maskektextbox to allow a decimal number (ex: 99.999). Then I save the input data in my table. It works fine. My question is how do I retrieve the decimal data of my table and put it in the maskedtextbox

thanks...





Re: Visual Basic Language Validating Textbox

Kea

What kind of 'table' are you using And what premises do you have to select data from the table I.e. indices, keys etc.




Re: Visual Basic Language Validating Textbox

NetPochi

SQlServer is my table. I retrieve a decimal data of a table and I want to put it in a maskedtextbox. Thanks...



Re: Visual Basic Language Validating Textbox

jwooley

Simply bind your data property to the .Text property of the MaxkedTextBox. Alternatively, you can programatically set the MaskedTextBox.Text = MyNumber.ToString().

Jim Wooley
http://devauthority.com/blogs/jwooley






Re: Visual Basic Language Validating Textbox

NetPochi

Thanks. I'd want to use the second option you give me, but It doesn't work. With the ToString method VB doesn't interpret the decimal party.



Re: Visual Basic Language Validating Textbox

DMan1

Sounds like the NumberBox user control is just what you need:

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1215559&SiteID=1