1 / 7
文档名称:

VB经典例题13道.docx

格式:docx   大小:16KB   页数:7页
下载后只包含 1 个 DOCX 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

VB经典例题13道.docx

上传人:国霞穿越 2020/11/14 文件大小:16 KB

下载得到文件列表

VB经典例题13道.docx

相关文档

文档介绍

文档介绍:一串字符求有多少字母,有多少数字,有多少其他
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