如何在录入MAC地址的时候,限制格式和字符
我想在 VB 里录入 AB-33-21-00-88-12
这样的 MAC 地址,
如果 限制 录入的 字符是 16进制内的 从0-9, A-F
而且不用 录入 中间的 -
Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
Text1(Index).MaxLength = 2
'AB-33-21-00-88-12
Dim L As Long
L = Text1(Index).SelStart
If L < 2 Then
If KeyAscii = 8 Then Exit Sub
If Not ((Asc("0") <= KeyAscii And KeyAscii <= Asc("9")) Or (Asc("A") <= KeyAscii And KeyAscii <= Asc("F")) Or (Asc("a") <= KeyAscii And KeyAscii <= Asc("f"))) Then
KeyAscii = 0
Else
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End If
If L = 1 And Index < 5 Then Text1(Index + 1).SetFocus
End If
End Sub