basic 实现 1,2,3,5,6,A,7转换为1-3,5,6,A,7

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/23 08:38:29
basic实现1,2,3,5,6,A,7转换为1-3,5,6,A,7basic实现1,2,3,5,6,A,7转换为1-3,5,6,A,7basic实现1,2,3,5,6,A,7转换为1-3,5,6,A

basic 实现 1,2,3,5,6,A,7转换为1-3,5,6,A,7
basic 实现 1,2,3,5,6,A,7转换为1-3,5,6,A,7

basic 实现 1,2,3,5,6,A,7转换为1-3,5,6,A,7
Private Sub Command1_Click()
On Error GoTo j
a = "1,2,3,5,6,A,7,8,9,10"
t = Split(a, ",")
For i = 0 To UBound(t)
If Val(t(i)) = Val(t(i + 1)) - 1 Then
n = n + 1
If lian = False Then m = t(i) & "&" & i & "&" & "true"
lian = True
Else
lian = False
If InStr(1, m, "true") = 0 Then m = t(i) & "&" & i & "&" & "false"
End If
If lian = False Then
h = Split(m, "&")
Print h(0) & "-" & t(Val(h(1)) + n)
m = ""
n = 0
End If
Next
j:
h = Split(m, "&")
Print h(0) & "-" & t(Val(h(1)) + n)
End Sub