VB 一简单程序

来源:百度知道 编辑:UC知道 时间:2024/05/30 13:45:31
程序要求:function
如输入:x!!!X 输出 x3!x
如输入:x!!!xy!!!!o 输出x3!xy4!o
就是这样
没有括号没有其他符号就 !
其他的就是 asc("a") to asc("z")

就这些
谢谢大家帮忙了

Option Explicit

Public Function ss(s As String)
Dim txt As String, t
Dim i As Integer
Dim j As Integer
Dim a(10) As Integer
j = 0
txt = s
For i = 1 To Len(txt)
If Asc(Mid(txt, i, 1)) = 33 Then
j = j + 1
Mid(txt, i, 1) = ""
Else
If j = 0 Then
t = t & Mid(txt, i, 1)
Else
t = t & j & "!" & Mid(txt, i, 1)
j = 0
End If
End If
Next

If j = 0 Then
t = t & Mid(txt, i, 1)
Else
t = t & j & "!" & Mid(txt, i, 1)
j = 0
End If

Text1.Text = t
End Function

Private Sub Command1_Click()
Dim s As String
s = Text1.Text
ss (s)

End Sub

Public Function ss(s As String)
Dim txt As String
Dim i As Integer
Dim j As Integer
Dim a(10) As Integer
j = 0
txt = s
For i = 1 To Len(txt)
If Asc(Mid(txt, i, 1)) = 33 Then
j = j + 1
Mid(txt