Search code examples
validationvb6

I want to give validation for mobile number in vb6


I give validation for mobile number but I want mobile number should start with 7,8,9 digits.I want to give validation that mobile number should start with 7,8,9 digits only.

If Len(TextBox11.Text) < 10 Or Len(TextBox11.Text) > 10 Then
                MsgBox("Enter the phone number in 10 digits!", vbExclamation, "")

This code is gives 10 digits validation but mobile number schould start with 7,8,9 digits.


Solution

  • 10 digits, starting 7,8,9

    isValid = TextBox11.Text like "[789]#########"
    
    if (not isValid) then
        msgbox "Invalid"
    ...