Hello - I am a beginner having problems with the validate event on a text box in a user control...can anyone give some advice...

Situation is.

Textbox must accept data in two formats:
Hex Sequence: 06H,05H,06H,FFH,FDH... (max value of an element = FFH)
Decimal Sequence:6,5,6,255,254... (max value of an element = 255)

There is also a variable read in at runtime which holds maximum number of either Hex or Dec elements in the text box.

I'm trying to write a validate event which checks that user has stuck to the rules above and am finding it quite tricky - any pointers or comments would be much appreciated...Heres what I've got so far...

Private Sub Text1_Validate()

Dim IsHexSequence As Boolean
Dim szSearchString As String
Dim arrByteSequenceElements As String
'Dim MaxNoOfElements As Integer

pSearchString = Text1.Text
'Check whether we are dealing with a hex or decimal sequence
If (InStr(1, szSearchString, "H") <> 0) Or (InStr(1, szSearchString, "h") <> 0) Then
IsHexSequence = True
End If

'Check that there are not more than maximum number of column separated elements
arrByteSequenceElements = Split(szSearchString, ",")
If (IsHexSequence) Then
'How can I check that number of elements doesn't exceed MaxNoOfElements?
'How can I check that the elements of the arrByteSequenceElements conform
'to the required hex sequence format of XXH,XXH,XXH?

End Sub

What can I say - if you have any ideas I'd love to hear them....thank you!
Regards,
Mairi