CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 1999
    Location
    California
    Posts
    264

    How can I plus two hex number?

    How can I plus two hex number?


    Dim a, b, c as string
    b = Hex(11)
    c = Hex(12)
    a = b + c




    it's not working. a is just add two b and c string together.

    Thanks!

    Best Regards,

    Kevin Shen
    Best Regards,

    Kevin Shen

  2. #2
    Join Date
    Apr 2000
    Posts
    737

    Re: How can I plus two hex number?

    you need a function to convet hex back to decimal, refer http://vblib.virtualave.net, there is a function called HexStr2Dec in vbStrings class.



    public vbStrings as new vbStrings
    Dim a, b, c as string
    dim d, e as byte

    b = Hex(11)
    c = Hex(12)
    d = vbStrings.HexStr2Dec(b)
    e = vbStrings.HexStr2Dec(c)
    a = Hex(d + e)




    HTH



  3. #3
    Join Date
    Aug 1999
    Location
    California
    Posts
    264

    Re: How can I plus two hex number?

    I have to convert hex back to decimal, then add them together? Do you know how I could add the two hex directly?

    Thanks!

    Best Regards,

    Kevin Shen
    Best Regards,

    Kevin Shen

  4. #4
    Join Date
    Apr 2000
    Posts
    737

    Re: How can I plus two hex number?

    try this


    Dim a, b, c as string

    b = Hex(11)
    c = Hex(12)
    e = Hex(val("&h" & b) + val("&h" & c))






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

Featured