Results 1 to 6 of 6

Thread: please can someone help me convert this

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    please can someone help me convert this

    this is a vb function

    VB Code:
    1. Public Function DeHexGkpr(Data As String) As String
    2.   Dim iCount As Integer, Temp As String
    3.   For iCount = 1 To 33 Step 2
    4.     Temp = Mid$(Data, iCount, 2)
    5.     If Temp = "0A" Then
    6.       DeHexGkpr = DeHexGkpr & "\n"
    7.     ElseIf Temp = "20" Then
    8.       DeHexGkpr = DeHexGkpr & "\b"
    9.     ElseIf Temp = "0D" Then
    10.       DeHexGkpr = DeHexGkpr & "\r"
    11.     ElseIf Temp = "2C" Then
    12.       DeHexGkpr = DeHexGkpr & "\c"
    13.     ElseIf Temp = "5C" Then
    14.       DeHexGkpr = DeHexGkpr & "\\"
    15.     ElseIf Temp = "00" Then
    16.       DeHexGkpr = DeHexGkpr & "\0"
    17.     ElseIf Temp = "07" Then
    18.       DeHexGkpr = DeHexGkpr & "\t"
    19.     Else
    20.       DeHexGkpr = DeHexGkpr & Chr$(Val("&H" & Temp))
    21.     End If
    22.   Next iCount
    23. End Function

    the parameter fed into DeHexGkpr is a random 32 character hexstring
    0-9, A-F

    Please can someone help me convert this into a c++ function?
    it takes every 2 characters at a time and turns it into their coressponding escape character

  2. #2
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037

    Re: please can someone help me convert this

    Find a VB to C++ converter on the web.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    Re: please can someone help me convert this

    ok thanks, do you know of any free converters?

  4. #4
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037

    Re: please can someone help me convert this

    Not off hand.

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    Re: please can someone help me convert this

    ok thanks but can someone tell me what this part does:

    Chr$(Val("&H" & Temp))

    whats the &H and Val, e.g &H07

    im gona try and give it a go myself

  6. #6
    Fanatic Member twanvl's Avatar
    Join Date
    Dec 2001
    Posts
    771

    Re: please can someone help me convert this

    That is the vb way of converting a hexadecimal string to a number and that number to a character. In C++ you would do:
    Code:
    std::string temp = "8c"; // some hex string
    char c = atio(temp.c_str());

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width