设计界面:
代码:
Private Sub Command1_Click()
Dim IntegerPart As Long, DecimalPart As Double
Dim Carry(), CharacterCode(15) As String
Carry = Array(2, 8, 16)
IntegerPart = Int(Val(Text1.Text))
DecimalPart = Val(Text1.Text) - Int(Val(Text1.Text))
For i = LBound(CharacterCode) To UBound(CharacterCode)
Select Case i
Case 0 To 9
CharacterCode(i) = Chr(48 + i)
Case Else
CharacterCode(i) = Chr(55 + i)
End Select
Next i
For i = LBound(Carry) To UBound(Carry)
Label2(i) = Transformation(Carry(i), CharacterCode, IntegerPart, DecimalPart)
Next i
End Sub
Private Function Transformation(ByVal CarrySystem As Integer, ByRef CharacterCode() As String, ByVal IntegerPart As Long, ByVal DecimalPart As Double) As String
Dim r As Integer, strIntegerPart As String, q As Integer, strDecimalPart As String
Do
r = IntegerPart Mod CarrySystem
IntegerPart = IntegerPart \ CarrySystem
strIntegerPart = CharacterCode(r) + strIntegerPart
Loop Until IntegerPart = 0
Do
q = Int(DecimalPart * CarrySystem)
DecimalPart = DecimalPart * CarrySystem - q
strDecimalPart = strDecimalPart + CharacterCode(q)
Loop Until DecimalPart = 0
Transformation = strIntegerPart + "." + strDecimalPart
End Function
运行界面: