Mesran

Hanya ingin berbagi kebaikan dan mendapatkan kebaikan yang lain.

Program Merubah Text Pesan ke Format PDU

Berikut ini program nya :

Form PDU

Private Sub Command1_Click()
    PDU = txt2pdu(Pesan)
End Sub

Private Sub Form_Load()
    hapus
End Sub

Sub hapus()
    Pesan = ""
    PDU = ""
    Jumlah = ""
    Biner = ""
End Sub

Private Sub Pesan_Change()
    Jumlah = Len(Pesan)
End Sub

Module1.Bas
Public Function txt2pdu(ByVal stxt As String) As String
For Y = 1 To Len(stxt)
        x = Dec2Bin(Asc(Mid(stxt, Y, 1)))
        Text = x & Text
        Next Y
    l = Len(Text)
    s = l - 7
    out = Bin2Hex(Mid(Text, s, 8))
    Do Until s <= 8
    s = s - 8
    out = out & Bin2Hex(Mid(Text, s, 8))
    Loop
    out = out & Bin2Hex(Mid(Text, 1, s - 1))

    x = Hex(Len(stxt))
    If Len(x) = 1 Then
            x = "0" & x
        End If
    txt2pdu = x & out
End Function

Public Function Dec2Bin(ByVal nDec As Integer) As String
    Dim i As Integer
    Dim j As Integer
    Dim sHex As String
    Const HexChar As String = "0123456789ABCDEF"

    sHex = Hex(nDec)

    For i = 1 To Len(sHex)
        nDec = InStr(1, HexChar, Mid(sHex, i, 1)) - 1

        For j = 3 To 0 Step -1
            Dec2Bin = Dec2Bin & nDec \ 2 ^ j
            nDec = nDec Mod 2 ^ j
        Next j
    Next i
    i = InStr(1, Dec2Bin, "1")
    If i <> 0 Then Dec2Bin = Mid(Dec2Bin, i)
    If Len(Dec2Bin) = 6 Then Dec2Bin = "0" & Dec2Bin
End Function

Public Function Bin2Hex(ByVal sBin As String) As String
    Dim i As Integer
    Dim nDec As Long
    sBin = String(4 - Len(sBin) Mod 4, "0") & sBin

    For i = 1 To Len(sBin)
        nDec = nDec + CInt(Mid(sBin, Len(sBin) - i + 1, 1)) * 2 ^ (i - 1)
    Next i
    Bin2Hex = Hex(nDec)
    If Len(Bin2Hex) Mod 2 = 1 Then Bin2Hex = "0" & Bin2Hex
End Function

Hasil Program :

Filed under: AT Commands, Metode-Algoritma-Teknik, SMS Gateway, VB Tips, , , ,

2 Responses

  1. untuk konversi dari PDU ke text nya ga sekalian?

  2. Aghoy says:

    Softwareny bisa didownload dmn??

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

Sponsored

C&C Online Shop

Blog Stats

  • 355,909 sejak 12 Jan 2011

User’s Online


My Music

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 223 other followers

June 2011
M T W T F S S
« May   Jul »
 12345
6789101112
13141516171819
20212223242526
27282930  
%d bloggers like this: