VB算法:从字母数字组成的字符串中找出所有大写字母,并逆序输出。 越简单越好。
展开全部
假设你的字符串已经在变量s里面了:
Sub 按字符逆序输出大写字母()
Dim i As Integer, s As String
Dim x As Integer, c As String
Dim arr(1 To 26) As Integer
s = InputBox("输入字符串")
For i = 1 To 26
arr(i) = 0
Next i
For i = 1 To Len(s)
c = Mid(s, i, 1)
If c >= "A" And c <= "Z" Then
x = Asc(c) - Asc("A") + 1
arr(x) = arr(x) + 1
End If
Next i
c = ""
For i = 26 To 1 Step -1
If arr(i) > 0 Then c = c & Chr(Asc("A") + i - 1)
Next i
MsgBox "你的字符串中出现的大写字母有:" & c
End Sub
展开全部
假设你的字符串已经在变量s里面了:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Sub 按字符逆序输出大写字母()
Dim i As Integer, s As String
Dim x As Integer, c As String
Dim arr(1 To 26) As Integer
s = InputBox("输入字符串")
For i = 1 To 26
arr(i) = 0
<a href="https://www.baidu.com/s?wd=Next&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YLPhRznAfvPHuhPyDkm1RY0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6K1TL0qnfK1TL0z5HD0IgF_5y9YIZ0lQzqlpA-bmyt8mh7GuZR8mvqVQL7dugPYpyq8Q1D1PWT3rjTdrH6znHm3nHTsnHb" target="_blank" class="baidu-highlight">Next</a> i
For i = 1 To Len(s)
c = Mid(s, i, 1)
If c >= "A" And c <= "Z" Then
x = Asc(c) - Asc("A") + 1
arr(x) = arr(x) + 1
End If
<a href="https://www.baidu.com/s?wd=Next&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YLPhRznAfvPHuhPyDkm1RY0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6K1TL0qnfK1TL0z5HD0IgF_5y9YIZ0lQzqlpA-bmyt8mh7GuZR8mvqVQL7dugPYpyq8Q1D1PWT3rjTdrH6znHm3nHTsnHb" target="_blank" class="baidu-highlight">Next</a> i
c = ""
For i = 26 To 1 Step -1
If arr(i) > 0 Then c = c & Chr(Asc("A") + i - 1)
<a href="https://www.baidu.com/s?wd=Next&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YLPhRznAfvPHuhPyDkm1RY0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6K1TL0qnfK1TL0z5HD0IgF_5y9YIZ0lQzqlpA-bmyt8mh7GuZR8mvqVQL7dugPYpyq8Q1D1PWT3rjTdrH6znHm3nHTsnHb" target="_blank" class="baidu-highlight">Next</a> i
MsgBox "你的字符串中出现的大写字母有:" & c
End Sub
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Sub 按字符逆序输出大写字母()
Dim i As Integer, s As String
Dim x As Integer, c As String
Dim arr(1 To 26) As Integer
s = InputBox("输入字符串")
For i = 1 To 26
arr(i) = 0
<a href="https://www.baidu.com/s?wd=Next&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YLPhRznAfvPHuhPyDkm1RY0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6K1TL0qnfK1TL0z5HD0IgF_5y9YIZ0lQzqlpA-bmyt8mh7GuZR8mvqVQL7dugPYpyq8Q1D1PWT3rjTdrH6znHm3nHTsnHb" target="_blank" class="baidu-highlight">Next</a> i
For i = 1 To Len(s)
c = Mid(s, i, 1)
If c >= "A" And c <= "Z" Then
x = Asc(c) - Asc("A") + 1
arr(x) = arr(x) + 1
End If
<a href="https://www.baidu.com/s?wd=Next&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YLPhRznAfvPHuhPyDkm1RY0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6K1TL0qnfK1TL0z5HD0IgF_5y9YIZ0lQzqlpA-bmyt8mh7GuZR8mvqVQL7dugPYpyq8Q1D1PWT3rjTdrH6znHm3nHTsnHb" target="_blank" class="baidu-highlight">Next</a> i
c = ""
For i = 26 To 1 Step -1
If arr(i) > 0 Then c = c & Chr(Asc("A") + i - 1)
<a href="https://www.baidu.com/s?wd=Next&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YLPhRznAfvPHuhPyDkm1RY0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6K1TL0qnfK1TL0z5HD0IgF_5y9YIZ0lQzqlpA-bmyt8mh7GuZR8mvqVQL7dugPYpyq8Q1D1PWT3rjTdrH6znHm3nHTsnHb" target="_blank" class="baidu-highlight">Next</a> i
MsgBox "你的字符串中出现的大写字母有:" & c
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command1_Click()
Dim s As String, t As String
Dim slen As Integer
s = InputBox("请输入串")
slen = Len(s)
For i = 1 To slen
m = Mid(s, i, 1)
If m >= "A" And m <= "Z" Then t = m & t
Next
Print t
End Sub
Dim s As String, t As String
Dim slen As Integer
s = InputBox("请输入串")
slen = Len(s)
For i = 1 To slen
m = Mid(s, i, 1)
If m >= "A" And m <= "Z" Then t = m & t
Next
Print t
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询