使用一个单重的循环扫描这个字符串中的所有字符,对每一个字符的出现次数进行统计,最后输出每个字符的出现次数。
成都创新互联公司于2013年开始,先为塔城等服务建站,塔城等地企业,进行企业商务咨询服务。为塔城企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。
Private Sub Command1_Click()
s = InputBox("请输入一个英文字符串:")
Dim a(128) As Integer
For i = 1 To Len(s)
t = Asc(Mid(s, i, 1))
a(t) = a(t) + 1
Next i
For i = 1 To 127
If a(i) 0 Then Print Chr(i); ":"; a(i)
Next i
End Sub
调用 脚本解析引擎,
textbox2.text=Eval(textbox1.text).ToString()
Function Eval(ByVal Expressions As String) As Double
Dim Mssc = CreateObject("MSScriptControl.ScriptControl")
Mssc.Language = "vbscript"
Return CDbl( Mssc.Eval(Expressions))
End Function
不喜欢上面提示的警告的话
textbox2.text=EvalString(textbox1.text)
Function EvalString(ByVal Expressions As String) As String
dim oType = System.Type.GetTypeFromProgID("MSScriptControl.ScriptControl")
Dim o = System.Activator.CreateInstance(oType)
oType.InvokeMember("Language", System.Reflection.BindingFlags.SetProperty , Nothing, o,New Object(){ "vbscript"})
Return oType.InvokeMember("Eval", System.Reflection.BindingFlags.InvokeMethod, Nothing, o, New Object(){Expressions}).ToString()
End Function
Eval 在VB中使用,刚找到的_vb吧_百度贴吧
Dim str1 As String = "112113114111"
Dim str2 As String = "11"
Dim count As Integer = 0
For i As Integer = 0 To str1.Length - 1
Dim f As Integer = str1.IndexOf(str2, i)
If f -1 Then
MsgBox("str2出现在str1的" f "个字符位置")
i = f
count += 1
End If
Next
MsgBox("统计出str1中共有" count "个str2!")
售后响应及时
7×24小时客服热线数据备份
更安全、更高效、更稳定价格公道精准
项目经理精准报价不弄虚作假合作无风险
重合同讲信誉,无效全额退款