下列VB程序实现数字字母混合序列分离后分别排序,最后又合并输出。具体算法如下:在文本框Text1输入若干组混合序列,每组序列中仅包含一组字母和一个多位数字,序列之间用逗号隔开,以逗号结束。单击“排序”按钮command1,把每组序列中的字母和数字分开,并分别排序,最后在列表框list1输出。排序规则如下:所有数字按从小到大升序排序,字母序列按长度升序排序,若长度相同,直接按字母序列大小升序排序(按字母的ASCII码排序,“A”<“Z”<“a”<“z”)。实现算法的部分程序界面如图所示,VB程序代码如下,回答下列问题:
Private Sub Command1_Click()
Dim a(1 To 6) As Integer, b(1 To 6) As String, i as integer, j as integer
Dim c As String, k As Integer, tmp1 As Integer, tmp2 As String
s=text1.text
i = 1: k = 1: tmp1 = 0: tmp2 = ""
Do While i <= Len(s)
c = Mid(s, i, 1)
If c = "," Then
a(k) = tmp1: b(k) = tmp2
tmp1 = 0: tmp2 = ""
①
Else
If Then
tmp2 = tmp2 + c
Else
tmp1=tmp1*10+val(c)
End If
End If
i = i + 1
Loop
For i = 1 To 5
For j = 1 To 6 - i
If a(j) > a(j + 1) Then tmp1 = a(j): a(j) = a(j + 1): a(j + 1) = tmp1
If Len(b(j)) > Len(b(j + 1)) Or ② Then
tmp2 = b(j): b(j) = b(j + 1): b(j + 1) = tmp2
End If
Next j
Next i
For i = 1 To 6
List1.AddItem Str(a(i)) + b(i)
Next i
End Sub