作业帮 > 综合 > 作业

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

来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/10 22:51:57
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 Su