برای اینکه یک تعداد کاراکتر خاص را در TextBox محدود کنیم میتوانیم از روش زیر استفاده نماییم.
به طور مثال :
مثلاً اجازه دهیم فقط کاراکترهای "0123456789ABCDEFabcdef" در TextBox تایپ گردد.
Option Explicit
Public Sub TextFilter(KeyAscii As Integer)
Dim strValid As String
strValid = "0123456789ABCDEFabcdef"
If KeyAscii > 26 Then
If InStr(strValid, Chr(KeyAscii)) = 0 Then
KeyAscii = 0
End If
End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
TextFilter KeyAscii
End Sub
شنبه ششم خرداد ۱۳۹۶ | 10:26