为什么要发明16进制呢?答:8进制16进制来源于2进制,有些数串太长用二进制不方便,用十六进制更方便人们看.
Private Sub Command1_Click()
Dim a As Integer
Dim b As Integer
Dim s As String
Dim yushu As Byte
a = 1230: b = 16
While a <> 0
yushu = a Mod b
s = f(yushu) & s
a = a \ b
Wend
Print s
End Sub
Private Function f(yushu As Byte) As String
If yushu <= 9 Then
f = yushu
Else
Select Case yushu
Case 10, 11, 12, 13, 14, 15
f = Chr(yushu + 55)
End Select
End If
End Function
选择排序法
Private Sub Command1_Click()
Dim a(10) As Integer
Dim i As Integer
For i = i To 10
a(i) = 10 + Int(Rnd() * 100)
Print a(i)
Next i
'按选择排序法排序
Dim j As Integer
For j = 1 To 9
For i = j + 1 To 10
If a(j) < a(i) Then
swap a(j), a(i)
End If
Next i
Next j
For i = 1 To 10
Print a(i)
Next i
End Sub
Private Sub swap(a As Integer, b As Integer)
Dim t As Integer
t = a
a = b
b = t
End Sub
'按冒泡排序法排序
Dim b As Integer
Dim j As Integer
For i = 1 To 9
For j = 1 To 10 - i
If a(j) < a(j + 1) Then
b = a(j + 1)
a(j + 1) = a(j)
a(j) = b
End If
Next j
For k = 1 To 10
'a(i) = 10 + Int(Rnd() * 100)
Print a(k);
Next k
Next i
End Sub