Link to home
Start Free TrialLog in
Avatar of m0tSiE
m0tSiE

asked on

Check textbox contians "DWD" followed by 5 HEX characters?

Hi,

I'm using the below code to check my textbox has a value of "DWD" and 5 hex characters, e.g. DWD00A0A. It doesn't seem to work with the (5) after the HEX part of the validation, although it does work without the (5) in there, although it means users can enter more than 5 HEX characters.

can anyone see why this is not working?

Thanks,
Paul.
If Not Regex.IsMatch(Respond_DWD.Text, "^[D]{1}[W]{1}[D]{1}[A-Fa-f0-9](5)$") Then
            MessageBox.Show("Please enter users workstation id in the correct format (E.G. DWD1A2B3)." & vbNewLine & vbNewLine & "E.G. DWD00A0A")
End If

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of abel
abel
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of m0tSiE
m0tSiE

ASKER

Yeah, I just realised I used rounded brackets on the number instead of the other ones.

Cheers.
Avatar of m0tSiE

ASKER

Cheers! :D
Note also the your "[D]{1}[W]{1}[D]{1}" is more easily readable as "DWD"...

glad to be of some help :)