VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Converts hexadecimal pdu format to ascii text open as a standard exe VB application we should add a

by jitendra/srinivas (1 Submission)
Category: Math/Dates
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 23rd September 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Converts hexadecimal pdu format to ascii text open as a standard exe VB application we should add a command button on the form

API Declarations


Dim str1 As String
Dim length As Integer
Dim strarr(20) As String
Dim j As Integer
Dim c As Integer
Dim strnum As Integer
Dim alpha As String
Dim strhexbin As String
Dim strhextobin As String
Dim strlast As String

Rate Converts hexadecimal pdu format to ascii text open as a standard exe VB application we should add a



        
    str = "E8329BFD06CDE56977DA1E9E83D0EF3B480EAA03"
    str1 = "E8329BFD06CDE56977DA1E9E83D0EF3B480EAA03"
    length = Len(str)
    j = 1
    length1 = Len(str) \ 2
    For i = 0 To length1
        strarr(i) = Mid(str, j, 2)
        j = j + 2
    Next i
    For i = 0 To length1 - 1
        str = strarr(i)
        strnum = 0
        For j = 1 To 2
            alpha = Mid(str, j, 1)
            c = GetDecimal(alpha)
            If j = 1 Then
                c = c * 16
            Else
                c = c * 1
            End If
            strnum = strnum + c
        Next j
        strhextobin = hextobin(strnum)
        strhexbin = strhexbin + strhextobin
    Next i
    If length Mod 2 <> 0 Then
        strlast = Mid(str1, length, 1)
        strlast = hextobin(CInt(strlast))
        strhexbin = strhexbin + strlast
    End If
    Call bintodec(strhexbin)
End Sub

Public Function GetDecimal(alpha As String) As Integer
Select Case UCase(alpha)
Case "A"
alpha = 10
Case "B"
alpha = 11
Case "C"
alpha = 12
Case "D"
alpha = 13
Case "E"
alpha = 14
Case "F"
alpha = 15
Case Else
alpha = alpha
End Select
GetDecimal = alpha
End Function

Public Function hextobin(strnum As Integer) As String
    Dim number As String
    Dim strnumber As String
    strnumber = ""
    
    Do Until strnum = 0 Or strnum = 1
        number = CStr(strnum Mod 2)
        strnumber = strnumber + number
        strnum = strnum \ 2
    Loop
    strnumber = strnumber + CStr(strnum)
    If Len(strnumber) < 8 Then
        k = 8 - Len(strnumber)
        For j = 1 To k
            strnumber = strnumber + "0"
        Next j
    End If
    hextobin = strnumber
End Function
Public Function bintodec(strhexbin As String)
    Dim lnt As Integer
    Dim strd As String
    Dim strsum As String
    lnt = Len(strhexbin)
    For i = 1 To lnt - (lnt Mod 7)
        strd = Mid(strhexbin, i, 7)
        istr = ascstr(StrReverse(strd))
        i = i + 6
        strsum = strsum + CStr(Chr(istr))
    Next i
    MsgBox strsum
End Function
Public Function ascstr(strd As String) As Integer
    Dim dec As Integer
    Dim spl As Integer
    Dim strsum As Integer
    i = 7
    j = 0
    Do Until i < 1
        spl = CInt(Mid(strd, i, 1))
        strsum = strsum + spl * 2 ^ j
        i = i - 1
        j = j + 1
    Loop
    ascstr = strsum
End Function


Download this snippet    Add to My Saved Code

Converts hexadecimal pdu format to ascii text open as a standard exe VB application we should add a Comments

No comments have been posted about Converts hexadecimal pdu format to ascii text open as a standard exe VB application we should add a. Why not be the first to post a comment about Converts hexadecimal pdu format to ascii text open as a standard exe VB application we should add a.

Post your comment

Subject:
Message:
0/1000 characters