You can use Mid() , Left() or Right() function to get The first four characters and the last 3 characters and Use Len() for the length of text.

Edited 4 Years Ago by Jx_Man: n/a

You can use Mid() , Left() or Right() function to get The first four characters and the last 3 characters and Use Len() for the length of text.

Thank you for the suggestion.
This how far i'm doing. But i don't know how to check if last 3 character is number?

Private Sub Command1_Click()
Dim First4Char, Last3Char As String
First4Char = Mid(Text1.Text, 1, 4)
Last3Char = Mid(Text1.Text, 5, 7)
If Len(Text1.Text) <= 7 Then
    If First4Char <> "ABCD" Then
        MsgBox "Wrong"
    End If
    ' How i can check if last 3 char is numbers?
    
End If
End Sub

Edited 4 Years Ago by Sturdy: n/a

This how far i'm doing. But i don't know how to check if last 3 character is number?

Use IsNumeric() function :

Private Sub Command1_Click()
Dim First4Char, Last3Char As String
First4Char = Mid(Text1.Text, 1, 4)
Last3Char = Mid(Text1.Text, 5, 7)
If Len(Text1.Text) <= 7 Then
    If First4Char <> "ABCD" Then
        MsgBox "Wrong"
    Else
        If Not IsNumeric(Last3Char) Then
            MsgBox "Wrong Input"
        Else
            ' Action if text is accepted
        End If
    End If
End If
End Sub

Edited 4 Years Ago by Jx_Man: n/a

Comments
It worked very nice. :D

Use IsNumeric() function :

Private Sub Command1_Click()
Dim First4Char, Last3Char As String
First4Char = Mid(Text1.Text, 1, 4)
Last3Char = Mid(Text1.Text, 5, 7)
If Len(Text1.Text) <= 7 Then
    If First4Char <> "ABCD" Then
        MsgBox "Wrong"
    Else
        If Not IsNumeric(Last3Char) Then
            MsgBox "Wrong Input"
        Else
            ' Action if text is accepted
        End If
    End If
End If
End Sub

Thank you sir. It worked very nice.

This question has already been answered. Start a new discussion instead.