用vb 例如:输入a,b,c,a,c,a 显示:a 3个 b 1个 c 2个
3个回答
展开全部
画一个文本框和一个按钮,在文本框里输入,然后点按钮看结果
Private Sub Command1_Click()
For i = 1 To Len(Text1.Text)
Select Case Mid(Text1.Text, i, 1)
Case "a"
a = a + 1
Case "b"
b = b + 1
Case "c"
c = c + 1
End Select
Next i
MsgBox "a有" + Str(a) + "个,b有" + Str(b) + "个,c有" + Str(c) + "个", , "结果"
End Sub
Private Sub Command1_Click()
For i = 1 To Len(Text1.Text)
Select Case Mid(Text1.Text, i, 1)
Case "a"
a = a + 1
Case "b"
b = b + 1
Case "c"
c = c + 1
End Select
Next i
MsgBox "a有" + Str(a) + "个,b有" + Str(b) + "个,c有" + Str(c) + "个", , "结果"
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Dim str, strshow, a As String
str = "a,b,c,a,c,a,d,h,j,j,h,d,a,f"
str1 = Split(str, ",")
For j = 0 To UBound(str1)
If InStr(a, str1(j)) = 0 Then
strshow = strshow & str1(j) & "有" & UBound(Split(str, str1(j))) & "个" & vbCrLf
End If
a = a & str1(j)
Next
Print strshow
str = "a,b,c,a,c,a,d,h,j,j,h,d,a,f"
str1 = Split(str, ",")
For j = 0 To UBound(str1)
If InStr(a, str1(j)) = 0 Then
strshow = strshow & str1(j) & "有" & UBound(Split(str, str1(j))) & "个" & vbCrLf
End If
a = a & str1(j)
Next
Print strshow
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
一楼正解,其实方法有很多种的,你可以改成你喜欢的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询