VB用sub或function输入一串包含字母大写小写数字的字符,输出字母个数

用COMMAND,inputbox,print啊。比如输入ABCabc123.输出6。拜托!

Private Sub Worksheet_Change(ByVal Target As Range)
Dim sInput As String
Dim i As Integer, iCount As Integer
Dim sChr As String

sInput = InputBox("Pls input a string:", "Input")
For i = 1 To Len(sInput)
sChr = Mid(sInput, i, 1)
If (Asc(sChr) >= 65 And Asc(sChr) <= 90) Or _
(Asc(sChr) >= 97 And Asc(sChr) <= 122) Then
iCount = iCount + 1
End If
Next i
MsgBox ("共有字母" + Str(iCount) + "个!")
print "共有字母" + Str(iCount) + "个!" //这一句不确定能否正常执行
End Sub
温馨提示:内容为网友见解,仅供参考
无其他回答

VB用sub或function输入一串包含字母大写小写数字的字符,输出字母...
Next i MsgBox ("共有字母" + Str(iCount) + "个!")print "共有字母" + Str(iCount) + "个!" \/\/这一句不确定能否正常执行 End Sub

用vb编程统计一段英文中大写字母、小写字母、空格、数字以及其他字符的...
Text2 = Text2.Text & "小写字母个数为:" & b & Chr(13) & Chr(10)Text2 = Text2.Text & "空格的个数为:" & c & Chr(13) & Chr(10)Text2 = Text2.Text & "数字的个数为:" & d & Chr(13) & Chr(10)Text2 = Text2.Text & "其他字符的个数为:" & e End Su...

vb如何计算文本框中的大写字母,小写字母,数字,其他字符的个数并在pic...
Picture1.Print "小写字母为"; n; "个"Picture1.Print "大写字母为"; m; "个"Picture1.Print "数字为"; k; "个"Picture1.Print "特殊符号为"; l; "个"End Sub

VB编写一个程序,统计输入的字符串中小写字母、大写字母、数字及其他符...
Private Sub Command1_Click()s = Len(Text1)For i = 1 To s If Mid(Text1, i, 1) <> 32 Then '没空格 If 97 < Asc(Mid(Text1, i, 1)) And Asc(Mid(Text1, i, 1)) < 122 Then a = a + 1 '小写字母 If 65 < Asc(Mid(Text1, i, 1)) And Asc(Mid(Text1, i,...

vb操作题输入一个字符串,统计大小写字母和数字个数
Private Sub Command1_Click() s = InputBox("请输入一个字符串:") n1 = 0: n2 = 0: n3 = 0 For i = 1 To Len(s) c = Mid(s, i, 1) If c >= "A" And c <= "Z" Then n1 = n1 + 1 If c >= "a" And c <= "z" Then n2 = n2 + 1 If...

VB从键盘上输入一串字符,以“?”结束,统计输入字符中的大、小写字母和...
xx As Integer, sz As Integer Print Chr(KeyAscii);Select Case KeyAscii Case 48 To 57 sz = sz + 1 Case 65 To 90 dx = dx + 1 Case 97 To 122 xx = xx + 1 Case 63 Print Print "大写字母:"; dx Print "小写字母:"; xx Print "数字:"; sz End Select End Sub ...

编一个vb程序,统计文本框中大写字母、小写字母及数字的个数
代码如下:Option ExplicitPrivate Sub Command1_Click()Dim i As IntegerDim Dn As IntegerDim Cn As IntegerDim Ln As IntegerDn = 0Cn = 0Ln = 0For i = 1 To Len(Text1.Text) If Mid(Text1.Text, i, 1) >= "0" And Mid(Text1.Text, i, 1) <= "9" Then Dn = D...

请教VB!!!任意输入一组字符,统计出大写字母多少个,小写字母多少个,数 ...
x + 1 Case "a" To "z"y = y + 1 Case "0" To "9"z = z + 1 Case Else End Select Next i Label1.Caption = "大写:" & x & "," & "小写:" & y & "," & "数字:" & z End Sub 运行结果见图:你的应该是变量不是全局变量,所以在其他过程中不能传递值。

vb中在一段字母中有大小写,怎样分别计算大.小写字母的个数
for i=1 to len(ss)s=mid(ss,i,1)if s>="A" and s<="Z" then dx=dx+1 elseif s>="a" and s<="z" then xx=xx+1 end if next msgbox "大写字母" & dx & "个" & vbcrlf & "小写字母" & xx & "个"

求一段VB语言,要求输入一串字符,找出其中的数字,大写英文,小写英文,空格...
Dim strUpper As String Dim strLower As String Dim strNumber As String Dim strTemp As String strText = Text1.Text If Len(strText) = 0 Then MsgBox "输入内容不能为空!", vbCritical, "提示"Exit Sub End If For i = 1 To Len(strText)strTemp = Mid(strText, i, 1)Select ...

相似回答
大家正在搜