文档介绍:一串字符求有多少字母,有多少数字,有多少其他
Private Sub Button1_Click(ByVal sender As , ByVal e As Handles Dim s, c, q, w, r s =
For i = 1 To Len(s) c = Mid(s, i, 1) If UCase(c) >= "A" And UCase(c) <= "Z" Then
q = q + 1 ElseIf c >= "0" And c <= "9" Then
w = w + 1
Else
r = r + 1
End If
Next
= "字母有 " & q & " 个 数字有 " & w & " 个 其他有 " & r & " 个 " End Sub
一串字符以结尾,求有多少字母,有多少数字,有多少其他
Private Sub Button1_Click(ByVal sender As , ByVal e As Handles Dim s, a, z, x, c, i s = a = Mid(s, 1, 1)
i = 1
Do While a <> ""
If UCase(a) >= "A" And UCase(a) <= "Z" Then
z = z + 1 ElseIf a >= "0" And a <= "9" Then
x = x + 1 Else
c = c + 1
End If
i = i + 1 a = Mid(s, i, 1)
Loop
= z & x & c
End Sub
给定一个数字求它是几位数字,如( 1) .12345 (2).-12345 (3).
Private Sub Button1_Click(ByVal sender As , ByVal e As Handles
Dim s, c, j
s =
c = Trim(Str(s))
If Int(c) = c Then If c >= 0 Then
= " 是 " & Len(c) & " 位数 "
Else
="是 ” & Len(c) - 1 & ” 位数”
Else
If c >= 0 The n
For i = 1 To Len(c)
If Mid(c, i, 1) = "." Then Exit For
j = j + 1
Next
="小数点前有” & j & ”位数” & "小数点后有” & Len(c) - j - 1 & ”位数”
Else
For i = 1 To Len(c)
If Mid(c, i, 1) = "." Then Exit For
j = j + 1
Next
="小数点前有” & j - 1 & ”位数” & ”小数点后有” & Len(c) - j - 1 & ”位数
End If
End If
End Sub
1 I 1 L _ n
I = “ • || ■ ■ I
4•求圆周率 公式. .
Private Sub Button1_Click(ByVal sender As , ByVai e As Handles
Dim a, s, n, pi
a = 1
n = 1
While (1 / n) >
pi