Mesran

Hanya ingin berbagi kebaikan dan mendapatkan kebaikan yang lain.

Mengkonversi Teks ke Biner

Hi met menjelang pagi nih.

😀 hehehehe, pagi pagi dah mau ngasih tips pemrograman nih. Pernahkah anda belajar mengenai Kriptografi ? atau mengenai keamanan data ?

Sering di pembelajaran tersebut kita berbicara data data biner yang terdiri dari 0 dan 1. Tetapi data yang sering kita bicarakan yaitu data teks. Nah bagaimana untuk mengkonversikan data teks tersebut ke data biner ?

Hal ini di lakukan karna teks teks yang akan diamankan selalu di konversikan ke biner atau ke hexa atau desimal.

Form Design

 

Listing Programnya :

Private Sub Command1_Click()
Dim i As Integer
Text2.Text = “”
For i = 1 To Len(Text1)
xdes = Mid(Text1, i, 1)
Text2.Text = Text2.Text + DesimalToBiner(Asc(xdes))
Next i
End Sub

Private Sub Form_Load()
Text1 = “”
Text2 = “”
End Sub

Function HEX_2_BIN(ByRef sHEX_DIGIT As String) As String
Dim xBin As String
Dim xbin2 As String
Dim xKata As String
Dim i As Integer

xbin2 = “”
For i = 1 To Len(sHEX_DIGIT)
xBin = “”
xKata = Mid(sHEX_DIGIT, i, 1)
Select Case UCase(xKata)
Case “0”
xBin = “0000”
Case “1”
xBin = “0001”
Case “2”
xBin = “0010”
Case “3”
xBin = “0011”
Case “4”
xBin = “0100”
Case “5”
xBin = “0101”
Case “6”
xBin = “0110”
Case “7”
xBin = “0111”
Case “8”
xBin = “1000”
Case “9”
xBin = “1001”
Case “A”
xBin = “1010”
Case “B”
xBin = “1011”
Case “C”
xBin = “1100”
Case “D”
xBin = “1101”
Case “E”
xBin = “1110”
Case “F”
xBin = “1111”
Case “h”, “H” ‘ ignore (suffix).
xBin = “”

Case Else
xBin = “”
End Select
xbin2 = xbin2 + xBin
Next i
HEX_2_BIN = xbin2
End Function

Function DesimalToBiner(ByRef Jumlah As Long) As String
Dim nBin As String
Dim chex As String
chex = Hex(Jumlah)
nBin = HEX_2_BIN(chex)
If Jumlah <= 15 Then nBin = “0000” & nBin
DesimalToBiner = nBin
End Function

Hasil Program :

Untuk program selengkapnya silahkan di unduh di sini.

Filed under: VB Tips,

4 Responses

  1. rico jm says:

    pak mantp ne…. aq sedot jgalah

  2. Meliani says:

    mantap nih pak..
    makasih ya…
    langsung disedotttt….🙂

Terima kasih telah memberikan komentar anda.

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Archives Per Tahun

%d bloggers like this: