直接复制代码运行
不像排序时清除picturebox
就注释掉Picture1.Cls
Dim n%, s(100) As String
Private Sub Form_Load()
Command1.Caption = "排序"
End Sub
Private Sub Command1_Click()
Picture1.Cls
Dim i%, j%
For i = 1 To n - 1
For j = i + 1 To n
If s(i) < s(j) Then
t = s(i)
s(i) = s(j)
s(j) = t
End If
Next j
Next i
For i = 1 To UBound(s)
Picture1.Print s(i)
Next i
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
s(n) = Text1.text
Picture1.Print s(n)
n = n + 1
End If
End Sub
Dim str1() As String, NN As Integer
Private Sub Command1_Click()
NN = NN + 1
ReDim Preserve str1(NN)
str1(NN) = Text1.Text
End Sub
Private Sub Command2_Click()
Dim i As Integer, j As Integer, str2 As String
Picture1.Cls
For i = 1 To NN - 1
For j = i + 1 To NN
If str1(i) > str1(j) Then str2 = str1(i): str1(i) = str1(j): str1(j) = str2
Next j
Next i
For i = 1 To NN - 1
Picture1.Print str1(i); " "
If i Mod 5 = 0 Then Picture1.Print
Next i
End Sub
Private Sub Form_Load()
Picture1.AutoRedraw = True
Text1.Text = ""
Command1.Caption = "增加"
Command2.Caption = "排序"
ReDim str1(NN)
End Sub
Dim asci()
Private Sub Command1_Click()
ReDim asci(1 To Len(Text1.Text))
For i = 1 To Len(Text1.Text)
asci(i) = Asc(Mid(Text1.Text, i, 1))
Next i
For i = 1 To Len(Text1.Text)
For j = i To Len(Text1.Text)
If asci(i) > asci(j) Then
t = asci(i): asci(i) = asci(j): asci(j) = t
End If
Next j
Next i
For i = 1 To Len(Text1.Text)
Picture1.Print Chr(asci(i))
Next i
End Sub
相信我做的简单,正确。试试看再说