convert ascii to hex form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • maharajakecil
    New Member
    • Mar 2008
    • 12

    convert ascii to hex form

    hi... anybody know the source code vb6.0 to convert asii to hex? thanks
  • QVeen72
    Recognized Expert Top Contributor
    • Oct 2006
    • 1445

    #2
    Hi,

    I'am not sure why would yo need to convert Ascii to HEX..?
    You can convert Dec to Hex , Bin to Hex, and Vice-e-versa..

    Regards
    Veena

    Comment

    • gobblegob
      New Member
      • Dec 2007
      • 133

      #3
      Originally posted by maharajakecil
      hi... anybody know the source code vb6.0 to convert asii to hex? thanks
      Hi Maharajakecil,

      create a new project add a new module and call it
      ModHexASCII

      also add 2 textboxes call them
      txtAscii and txtHex

      on the module add this..

      Code (vb 6)
      Code:
      Option Explicit
      
      Public Function HexIt(sText As String) As String
      Dim A As Long
      For A = 1 To Len(sText)
      HexIt = HexIt & Hex$(Asc(Mid(sText, A, 1))) & Space$(1)
      On Error Resume Next
      DoEvents
      Next A
      HexIt = Mid$(HexIt, 1, Len(HexIt) - 1)
      End Function
      on your form add a command button and add this...

      Code:
          If Len(txtAscii.Text) > 0 Then
          txtHex.Text = HexIt(txtAscii.Text)
      End If
      hope this helps you. If you need the code to convert from hex to ascii let me know and i will post for you.

      GobbleGob.

      Comment

      • maharajakecil
        New Member
        • Mar 2008
        • 12

        #4
        hi veena,
        i need to convert from ascii to hex because i need my GUi send an integer to my PIC circuit in hex form. the output from computer(GUI) is in ascii right? so i need the output from GUI in hex form so that i can send it directly to the PIC circuit. but i really dont know whether during tansmision of the output is in ascii or hex after convert it to hex form. i'm newest in GUI(VB). i had lost.....

        Comment

        • maharajakecil
          New Member
          • Mar 2008
          • 12

          #5
          hi gobbleGob
          you make my day bright again

          i want convert only integer to hex form.
          the range of integer will be 0 to 15 only.
          one more thing if i want send the output from vb to the hardware, the signal will be in hex form if i'm convert it into hex right?
          correct me if i'm wrong... thanks again.

          Comment

          • QVeen72
            Recognized Expert Top Contributor
            • Oct 2006
            • 1445

            #6
            Originally posted by maharajakecil
            the range of integer will be 0 to 15 only.

            Use Hex function for that...

            say, i is your Integer then,

            Hex( i )

            Regards
            Veena

            Comment

            • maharajakecil
              New Member
              • Mar 2008
              • 12

              #7
              thanks veena
              i had try but the transmission of the data to my PIC circuit is still in Ascii.

              Comment

              Working...