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.

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.

Edited 5 Years Ago by Unhnd_Exception: n/a

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?

This article has been dead for over six months. Start a new discussion instead.