Ako môžem obmedziť textové pole tak, aby prijímalo iba malé písmená s jedným veľkým písmenom alebo aspoň s 1 veľkým písmenom a číslom?
odpovede:
0 pre odpoveď č. 1Ak chcete skontrolovať, či reťazec obsahuje aspoň jeden horný znak, jeden dolný znak a jedno číslo, môžete použiť znak.IsUpper / IsLower / IsNumber metódy.
Private Function IsValidPasswordFormat(ByVal text As String) As Boolean
If String.IsNullOrEmpty(text) Then
Return False
End If
If text.Any(Function(c) Char.IsUpper(c)) AndAlso
text.Any(Function(c) Char.IsLower(c)) AndAlso
text.Any(Function(c) Char.IsNumber(c)) Then
Return True
End If
Return False
End Function
0 pre odpoveď č. 2
Predpokladajme, že str
je textbox.text
Dim ucount as integer
ucount=0
For Each c As Char In str
Dim charCode As Integer = AscW(c)
If charCode >= 65 AndAlso charCode < 91 Then
ucount += 1
End If
Next
if ucount>1
"do something
End If
Pri tom something
časť, napríklad môžete dať textbox.text=""