Hello everyone,

My company uses control numbers to keep track of all of our inventory for every product that is entered into our warehouse. (ex. G123456789, T987654321) 1st Alphabet followed by 9 digits of numbers.
Most of the time, these control numbers are scanned into the system by using a barcode scanner but some times these control number are entered into the system manually by hand.
People make mistakes and sometimes enter in different control number.

i want to be able to code my vb so that when the control number does not meet the critarion then program displays an error message.
So i want to check for the first character which needs to be an alphabet and characters 2-10 to be a number.

Member Avatar for Unhnd_Exception
Dim ControlNumber As String = "G123456789"

'to make lines fit on this post
Dim mStyle As MsgBoxStyle = MsgBoxStyle.OkOnly Or MsgBoxStyle.Critical

If String.IsNullOrEmpty(ControlNumber) Then
   MsgBox("Please enter a Control Number.", mStyle, "No Input Violation")
   Exit Sub
End If

If ControlNumber.Length <> 10 Then
   MsgBox("Control Number should be a length of ten.", mStyle, "Invalid Length Violation")
   Exit Sub
End If

If Not Char.IsLetter(ControlNumber(0)) Then
   MsgBox("First Letter Needs to be a Letter.",mStyle, "Invalid Input Violation")
   Exit Sub
End If

For i = 1 To ControlNumber.ToCharArray.Count - 1
   If Not Char.IsNumber(ControlNumber(i)) Then
       MsgBox("Expected Number at postion " & i + 1, mStyle, "Invalid Input Violation")
       Exit Sub
   End If
Next

'Control Number is in the correct format.
Member Avatar for Unhnd_Exception

I noticed you were online.

This wasn't good enough for you?

I'm sorry, I'm new to DaniWeb and having hard time finding my own threads.
I'm writing this application in VBA (MS Access 2007) so some of the language is little different. Now I have to figure out a way to convert this to VBA language.
Thanks for your help.

I think I need to move this thread to VB6 section.
How do I request for thread relocation?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.