split text into sections

abbers_01

Registered User.
Local time
Today, 14:24
Joined
Aug 31, 2007
Messages
45
I am making a code that has a format like this
A-##-##-##-##
B-###-##
C-##

I'm not sure what I would use in vbscript to be able to extract the letter, because it is that letter that determines the input mask of my text box.

Basically what I want is for a person to input their code and if they haven't followed the correct format based on the letter at the beginning, they get an error.

Is there a way to determine what the individual letters of a text box?

Thanks to anyone that can help.
 
The general schema would be something like this, with YourTextBox being the actual name of yours:
Code:
Private Sub YourTextBox_AfterUpdate()
 
Select Case Left(Me.YourTextBox, 1)
   
   Case "A"
   'Code to check for formatting of [B]A[/B] codes goes here
   
   Case "B"
   'Code to check for formatting of [B]B[/B] codes goes here
      
   Case "C"
   'Code to check for formatting of [B]C[/B] codes goes here
     
  Case Else
  'Code here for when no valid prefix is entered 
  Msgbox Left(Me.YourTextBox, 1) & " is not a proper Code Prefix!" 
End Select

End Sub
 
Last edited:

Users who are viewing this thread

Back
Top Bottom