Lencana Facebook
Driver Downloads
Halaman
Blog Archive
Entri Populer
Followers
Senin, 27 Februari 2012
Script VB Untuk Konversi Bilangan Desimal Ke Biner dan Biner Ke Desimal
08.51 |
Diposting oleh
NE-O
Buat 1 project dengan :
1 Form
2 CommandButton
2 TextBox
Private Sub Command1_Click()
Dim Decimal1 As Long
Dim Binary1 As String
Dim Binary2 As String
On Error GoTo ErrEnd
Binary1 = ""
Binary2 = ""
Decimal1 = Text1.Text
Do Until Decimal1 = 0
If Deelbaar2(Decimal1) = False Then
Binary2 = Binary2 & 1
ElseIf Deelbaar2(Decimal1) = True Then
Binary2 = Binary2 & 0
End If
Decimal1 = Int(Decimal1 / 2)
Loop
For a = Len(Binary2) To 1 Step -1
Binary1 = Binary1 & Mid(Binary2, a, 1)
Next a
Text2.Text = Binary1
Exit Sub
ErrEnd:
Alert = MsgBox("Error " & Err.Number & ": " & Err.Description, vbCritical)
End Sub
Private Sub Command2_Click()
On Error GoTo ErrEnd
For a = 1 To Len(Text2.Text)
If Mid(Text2.Text, a, 1) <> "0" And Mid(Text2.Text, a, 1) <> "1" Then
MsgBox "Wrong binary number!"
Exit Sub
End If
Next a
Dim Binary1 As String
Dim Decimal1 As Long
Decimal1 = 0
Binary1 = Text2.Text
For a = 1 To Len(Binary1)
Decimal1 = Decimal1 * 2 + Mid(Binary1, a, 1)
Next a
Text1.Text = Decimal1
Exit Sub
ErrEnd:
Alert = MsgBox("Error " & Err.Number & ": " & Err.Description, vbCritical)
End Sub
Private Function Deelbaar2(Getal As Long) As Boolean
If Getal = Int(Getal / 2) * 2 Then
Deelbaar2 = True
ElseIf Getal <> Int(Getal / 2) * 2 Then
Deelbaar2 = False
End If
End Function
http://www.planet-source-code.com
1 Form
2 CommandButton
2 TextBox
Source code :
Private Sub Command1_Click()
Dim Decimal1 As Long
Dim Binary1 As String
Dim Binary2 As String
On Error GoTo ErrEnd
Binary1 = ""
Binary2 = ""
Decimal1 = Text1.Text
Do Until Decimal1 = 0
If Deelbaar2(Decimal1) = False Then
Binary2 = Binary2 & 1
ElseIf Deelbaar2(Decimal1) = True Then
Binary2 = Binary2 & 0
End If
Decimal1 = Int(Decimal1 / 2)
Loop
For a = Len(Binary2) To 1 Step -1
Binary1 = Binary1 & Mid(Binary2, a, 1)
Next a
Text2.Text = Binary1
Exit Sub
ErrEnd:
Alert = MsgBox("Error " & Err.Number & ": " & Err.Description, vbCritical)
End Sub
Private Sub Command2_Click()
On Error GoTo ErrEnd
For a = 1 To Len(Text2.Text)
If Mid(Text2.Text, a, 1) <> "0" And Mid(Text2.Text, a, 1) <> "1" Then
MsgBox "Wrong binary number!"
Exit Sub
End If
Next a
Dim Binary1 As String
Dim Decimal1 As Long
Decimal1 = 0
Binary1 = Text2.Text
For a = 1 To Len(Binary1)
Decimal1 = Decimal1 * 2 + Mid(Binary1, a, 1)
Next a
Text1.Text = Decimal1
Exit Sub
ErrEnd:
Alert = MsgBox("Error " & Err.Number & ": " & Err.Description, vbCritical)
End Sub
Private Function Deelbaar2(Getal As Long) As Boolean
If Getal = Int(Getal / 2) * 2 Then
Deelbaar2 = True
ElseIf Getal <> Int(Getal / 2) * 2 Then
Deelbaar2 = False
End If
End Function
http://www.planet-source-code.com
Langganan:
Posting Komentar (Atom)
Like This Yo...!!
Translate this Blog
Chat Box
Label
- aksi bakar ban (1)
- Bai Fang Li Tukang Becak yang Berhati Mulia (1)
- cheat empire dan allies (1)
- Info keren (37)
- Info Music (14)
- Mengapa orang korupsi ? Analisa psikologi (1)
- Music Album (11)
- Prospek di masa depan mahasiswa TI dan mahasiswa SI (1)
- Quiz (2)
- Script VB Untuk Konversi Bilangan Desimal Ke Biner dan Biner Ke Desimal (1)
- Tips dan Trik (14)
- Tips danTrik Komputer (22)
0 komentar:
Posting Komentar