Kali ini postingan tentang konversi bilangan biner ke octal, berikut potongan kode program nya :
Private Function BinaryToDecimal(ByVal BinValue As String) As Long
Dim lngValue As Long
Dim x As Long
Dim k As Long
k = Len(BinValue) 'will only work with 30 or fewer "bits"
For x = k To 1 Step -1 'work backwards down string
If Mid$(BinValue, x, 1) = "1" Then
If k - x > 30 Then
lngValue = lngValue Or -2147483648# 'avoid overflow error
Else
lngValue = lngValue + 2 ^ (k - x)
End If
End If
Next x
BinaryToDecimal = lngValue
End Function
Private Sub Command1_Click()
bil1 = BinaryToDecimal(Text1)
Text2.Text = Oct(bil1)
End Sub
Programnya silahkan didownload
0 komentar:
Posting Komentar