Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Getting Textbox to read valid barcode in VB.Net

Author  Topic 

OfMartin
Starting Member

11 Posts

Posted - 2005-04-15 : 14:23:43
I'm creating a Visual Basic form that reads barcode in a textbox property inputed by the user. I need my textbox to read only ALPHA-NUMBERIC characters. If it doesn't read alphanumber characters, i have a read-only textbox that gives the user a warning if the input is not alphanumeric. The barcode that should be inputed alphanumerically would typically look like this "C098093240". Here's what I have so far...This code actually checks to see if the input is "numeric". I'm really stuck on this logic. I really need help bad. I've got a feeling all I need to is change around the coding within the quotation marks to make it read alphanumeric, but its just a hunch.

Dim x As Int16
Dim strNew As String = ""

'Review all characters in the txtBarcode text box to ensure that they are numeric digits
'Loop through all characters and pass numeric digits to a new string
For x = 0 To Len(txtBarcode.Text) - 1
If InStr("0123456789", txtBarcode.Text.Substring(x, 1)) > 0 Then
' Char is alpha-numeric
strNew += txtBarcode.Text.Substring(x, 1)
Else ' Char is not alpha-numeric
Beep() ' Warn user
lblHelp.Text = "Character is not numeric"
End If

Thanks a lot everyone,
OfMartin890@yahoo.com
   

- Advertisement -