HadiVB
پنج شنبه 20 اردیبهشت 1386, 21:00 عصر
:خجالت: هرکی یه راه آسون داره راهنمایی کنه لفطاَ
perfeshnal
پنج شنبه 20 اردیبهشت 1386, 21:09 عصر
سلام
دوست من بهتر بود اول یک جستجو می کردید.
http://barnamenevis.org/forum/showthread.php?t=66233
farzadvb
یک شنبه 23 اردیبهشت 1386, 07:04 صبح
از این تابع استفاده کن :
Public Function MaskText(txtTarget As VB.TextBox, strMask As String)
Static bolRunning As Boolean
If bolRunning Then
Exit Function
End If
bolRunning = True
Dim strTarget_Text As String
strTarget_Text = txtTarget.Text
Dim lngCursor_Pos As Long
lngCursor_Pos = txtTarget.SelStart
If Len(strMask) > Len(strTarget_Text) Then
strTarget_Text = strTarget_Text & Space(Len(strMask) - Len(strTarget_Text))
ElseIf Len(strMask) < Len(strTarget_Text) Then
strTarget_Text = Left(strTarget_Text, Len(strMask))
ElseIf Len(strMask) = 0 Then
Exit Function
End If
Dim strTarget_Char As String * 1
Dim strMask_Char As String * 1
Dim strTemp As String
Dim bolAlpha As Boolean
Dim aryLiterals As Variant
aryLiterals = Array("(", ")", "-", ".", ",", ":", ";", "/", "\", " ")
Dim lngLiteral_Index As Long
Dim bolLiteral As Boolean
Dim lngChar_Index As Long
For lngChar_Index = 1 To Len(strMask)
strTarget_Char = Mid(strTarget_Text, lngChar_Index, 1)
strMask_Char = Mid(strMask, lngChar_Index, 1)
For lngLiteral_Index = LBound(aryLiterals) To UBound(aryLiterals)
bolLiteral = (strMask_Char = aryLiterals(lngLiteral_Index))
If bolLiteral Then
Exit For
End If
Next lngLiteral_Index
Select Case strMask_Char
Case "#":
If (Not IsNumeric(strTarget_Char)) And (strTarget_Char <> " ") Then
strTemp = Right(strTarget_Text, Len(strTarget_Text) - lngChar_Index)
If lngChar_Index > 1 Then
strTarget_Text = Left(strTarget_Text, lngChar_Index - 1)
Else
strTarget_Text = ""
End If
strTarget_Text = strTarget_Text & " " & strTemp
End If
Case "@":
bolAlpha = ((Asc(strTarget_Char) >= 65) And (Asc(strTarget_Char) <= 90)) Or ((Asc(strTarget_Char) >= 97) And (Asc(strTarget_Char) <= 122))
If (Not bolAlpha) And (strTarget_Char <> " ") Then
strTemp = Right(strTarget_Text, Len(strTarget_Text) - lngChar_Index)
If lngChar_Index > 1 Then
strTarget_Text = Left(strTarget_Text, lngChar_Index - 1)
Else
strTarget_Text = ""
End If
strTarget_Text = strTarget_Text & " " & strTemp
End If
Case Else:
If (strTarget_Char <> strMask_Char) And bolLiteral Then
strTemp = Right(strTarget_Text, Len(strTarget_Text) - (lngChar_Index - 1))
strTarget_Text = Left(strTarget_Text, lngChar_Index - 1)
strTarget_Text = strTarget_Text & strMask_Char & strTemp
If lngChar_Index = lngCursor_Pos Then
lngCursor_Pos = lngCursor_Pos + 1
End If
End If
End Select
Next lngChar_Index
txtTarget.Text = Left(strTarget_Text, Len(strMask))
txtTarget.SelStart = lngCursor_Pos
bolRunning = False
End Function
vBulletin® v4.2.5, Copyright ©2000-1404, Jelsoft Enterprises Ltd.