Fungsi konversi dari angka menjadi biner visual basic 6
Private
Function NumToBin(Angka As Integer) As String
Dim Temp As Variant
Temp = 1
Do Until Temp > Angka
Temp = Temp * 2
Loop
Do Until Temp < 1
If Angka >= Temp Then
NumToBin = NumToBin + "1"
Angka = Angka - Temp
Else
NumToBin = NumToBin + "0"
End If
Temp = Temp / 2
Loop
NumToBin = CStr(Val(NumToBin))
End Function
Dim Temp As Variant
Temp = 1
Do Until Temp > Angka
Temp = Temp * 2
Loop
Do Until Temp < 1
If Angka >= Temp Then
NumToBin = NumToBin + "1"
Angka = Angka - Temp
Else
NumToBin = NumToBin + "0"
End If
Temp = Temp / 2
Loop
NumToBin = CStr(Val(NumToBin))
End Function
Comments
Post a Comment