Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Text Box Validation In Vb.net


  • Please log in to reply
2 replies to this topic

#1 RandomSkratch

RandomSkratch

  • Members
  • 32 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:12:26 PM

Posted 03 February 2006 - 05:57 PM

I was wondering how I would go about writing this IF statement for validation of data entered into certain text boxes.

IF data entered into QuantityTextBox.Text = Letters Then

Display Error (I can do the error msg)

ELSE

Perform the proper calculations (these are also already done)

END IF


I don't know how to say if the text box is = numerical values or alphabetical values. I've checked my school text book and the VB Help files but so far nothing.

Thanks

BC AdBot (Login to Remove)

 


#2 Jay Cat

Jay Cat

  • Members
  • 7 posts
  • OFFLINE
  •  
  • Local time:12:26 PM

Posted 04 February 2006 - 05:26 PM

I would use the KeyPress event to prevent letters from being entered.

#3 tsg1zzn

tsg1zzn

  • Members
  • 7 posts
  • OFFLINE
  •  
  • Local time:07:26 PM

Posted 13 February 2006 - 06:23 AM

Now I have never touched VB.Net, but here's some suggestions:

Do you have a function for returning only the numbers in a string? If so, you can assume that the string contains only numbers if the (length of string) = (length of onlynumbers(string)).

Since this .Net, I would assume that the text box has an input mask property for this very purpose.

Or, you can write a function yourself which walks through each character in the string and checks if it is numeric:
FUNCTION IsNumeric(s$) AS INTEGER 'Do you have a boolean type in VB.NET?
  Result.l = 1
  For i.l = 0 To Len(s$)
	If Mid(s$, I, 1) < "0" Or Mid(s$, I, 1) > "9"
	  Result = 0
	EndIf
  Next
  RETURN Result
END FUNCTION





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users