十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
使用一个单重的循环扫描这个字符串中的所有字符,对每一个字符的出现次数进行统计,最后输出每个字符的出现次数。
成都创新互联公司于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!")