①从左往右扫描,若其中存在连续上升数字字符,则进行压缩。其中,数字字符串“91”也算连续上升。连续上升的数字字符不超过9个,若超过9个则该数字字符串分成两段。例如:“12324789123456789”可以压缩成“1-3247-67-9”
②对压缩后的数字字符进行加密,其中,数字字符“1”-“9”用加密字符“A”-“I”表示,未经压缩的数字字符原样输出。例如:“1-3247-67-9”加密后是“A-C24G-FG-I”。
程序界面如图所示。
Private Sub Command1_Click()
Dim s As String, k As Integer, i As Integer, t As Integer
Dim sjg As String, mw As String, start1 As Integer, end1 As Integer Dim a(1 To 100) As Integer
mw = "ABCDEFGHI"
t = 1
a(1) =
For i = 2 To Len(s)
a(i) = Val(Mid(s, i, 1))
If Then
t = t + 1
Else
If t > 1 Then
start1 =
end1 = a(i - 1)
sjg = sjg + Mid(mw, start1, 1) + "-" + Mid(mw, end1, 1)
Else
sjg = sjg + CStr(a(i - 1)) ‘CStr 函数将表达式转换为字符串,并去除前导空格
End If
t = 1
End If
Next i
Text2.Text = sjg
End Sub