|
|
发表于 2008/6/5 08:41:57
|
显示全部楼层
VB代码如下:
'判断输入字符位数
Dim sz, kg, xzm, dzm, qt, i As Integer
If TextBox1.Text <> String.Empty Then
For i = 0 To TextBox1.Text.Length - 1
If CInt(Asc(TextBox1.Text.Substring(i, 1))) >= Asc("A") And CInt(Asc(TextBox1.Text.Substring(i, 1))) <= Asc("Z") Then
dzm += 1
ElseIf CInt(Asc(TextBox1.Text.Substring(i, 1))) >= Asc("a") And CInt(Asc(TextBox1.Text.Substring(i, 1))) <= Asc("z") Then
xzm += 1
ElseIf CInt(Asc(TextBox1.Text.Substring(i, 1))) >= Asc("0") And CInt(Asc(TextBox1.Text.Substring(i, 1))) <= Asc("9") Then
sz += 1
ElseIf CInt(Asc(TextBox1.Text.Substring(i, 1))) = Asc(" ") Then
kg += 1
Else
qt += 1
End If
Next
End If
Response.Write("大写字母:" & dzm & ",小写字母:" & xzm & ",数字:" & sz & ",空格:" & kg & ",其它:" & qt) |
|