|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
I am trying to do a validation on a scanned entry into a VB Text Box. I can break the string into the parts I need to validate. Here is an example:
I have a scanned entry of 'SE1234567' First I need to validate it is 9 characters long, DONE. 2nd, need to validate the first to characters are 'SE', DONE. 3rd, need to validate the last 7 characters are numbers and not letters, help.... Looking ahead I have a similar problem where a certain position on a string has to be a letter.... I have looked every where and tried many things, but can't get this one... Help would be GREATLY appriciated!!!! ![]() |
|
#2
|
||||
|
||||
|
I did this - I put a textbox on a blank form in vb6, left everything default names. The put your sample string ("SE1234567") in the textbox text property in the properties window, and put the following the load procedure
Code:
Private Sub Form_Load() Dim blnTrue As Boolean Dim strString As String blnTrue = IsNumeric(Mid(Text1.Text, 3, 7)) strString = CStr(Mid(Text1.Text, 3, 7)) MsgBox blnTrue & " " & strString End Sub
__________________
Fisherman "Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - A.Einstein |
|
#3
|
|||
|
|||
|
Great, now...
Fisherman,
thanks for the help. That did the trick for the numerical IsNumeric values, what about letters? IsAlpha something? Thanks again. Joe |
|
#4
|
||||
|
||||
|
well, could you just do the inverse of the previous logic? IsNumeric will return a Boolean Value - True if it is, False if it isn't. If you call isNumeric(strValue) then you will get a return value of False
|
|
#5
|
|||
|
|||
|
Inverse
I thought about that, but it would be a problem if some how, they get some special characters in there. They would not be numeric, but also not letters either. For such a simple problem, I have spent a lot of time in this, strange.
Thanks in advance. JOE |
|
#6
|
||||
|
||||
|
well, it's been a while since I studied data structures, but aren't the Ascii values of special characters evaluated as less than the Ascii values of normal text? if so, then you could use something like this to find out if it's a special character or not...
Code:
public Function isSpecialCharacter(byval str5 as string) as boolean Dim str1 as string dim str2 as string dim str3 as string dim str4 as string str1 = "A" str2 = "Z" str3 = "a" str4 = "z" if str5 < str1 then return True Elseif str5 > str2 and str5 < str3 then return True elseif str5 > str4 then return true else return false end if end Function I just looked up an Ascii value table, there is one exception . The numeric values are less than "A", so you'll need to verify that isNumeric(value) = false before calling this function. the Ascii table is here . Hope it helps |
|
#7
|
|||
|
|||
|
if the scanner keep on scanning while the data have not process by the system, how many scanned data(with enter key pass in) will the text box keep?
I'm facing a problem when the data capture from barcode scanner(keyboard wedge) and pass to the system , some time will cause the system automatically exit. Any one know why this happen? |
|
#8
|
||||
|
||||
|
I have to do that in programs where I work. We have the ability to not accept a new object into the system until we have processed the existing one. I would suggest that following your processing, you clear your test boxes. Then, at the beginning of your processing, you can check for the length of the value of the text boxes. If the length is greater than 0, then you know there is something in the boxes, and therefore, there is data processing. In that instance, you can either stop the new object from entering the system, and accept it later, or you can add you values to an array of enumerated values, thus "buffering" the data, allowing you to process it when the thread is available.
|
|
#9
|
|||
|
|||
|
TQ Fisherman,
But i dun think i can block the object to be scan into system. Cause the system used in the production line which heavy data capture from scanner.The scan data need lots of verification until sometime the textbox will have few data in queue(mayb cause by verification or database blocking) . Is the system exit automatically related to the data scanned into textbox? If the textbox reach the max length, will it cause the exit problem? Any suggetion for handler such problem? |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Validating Text Box Scanned Entry |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|