Results 1 to 12 of 12

Thread: How to deal with hexadecimal values

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2007
    Posts
    36

    How to deal with hexadecimal values

    hi
    i write a programe to convert the ascii to hexadecimal then i want to write a function to deal with these hexadecimal value>>>> for better explain here is an exapmle:
    if i have these hexadecimal value 44 2A 66 E2 F6 77
    so i want to write a function that look to first character (44) to see what the values around it (before it and after it) and replace it is value depend on that such that replace the (44) with another value like (54) and then go to the next value(2A) and see the values before and the value after >>>>>
    which mean for example if it is found that the value before the value (2A) is (44) and the value after it is (66) replace it with (77) and if it found that the value before it is (E2) and the value after is (66) replace it with (F3) and so on.....
    and second problem how to make the function to see the the values as two bit not bit by bit which mean to look to the value 44 and then to 2A and so on not to look to each bit (see 4 then 4 then 2 then A)
    i hope you understand the idea
    and sorry for my english
    Last edited by king4ever101; Jun 27th, 2007 at 03:03 AM.

  2. #2

    Thread Starter
    Member
    Join Date
    Jun 2007
    Posts
    36

    Re: How to deal with hexadecimal values

    any idea to do that???

  3. #3
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: How to deal with hexadecimal values

    Quote Originally Posted by king4ever101
    hi
    i write a programe to convert the ascii to hexadecimal then i want to write a function to deal with these hexadecimal value>>>> for better explain here is an exapmle:
    if i have these hexadecimal value 44 2A 66 E2 F6 77
    so i want to write a function that look to first character (44) to see what the values around it (before it and after it) and replace it is value depend on that such that replace the (44) with another value like (54) and then go to the next value(2A) and see the values before and the value after >>>>>
    which mean for example if it is found that the value before the value (2A) is (44) and the value after it is (66) replace it with (77) and if it found that the value before it is (E2) and the value after is (66) replace it with (F3) and so on.....
    So you have a string and convert each character to its hex ascii value, in 44 2A 66 E2 F6 77 the spaces separate the characters, right?
    You menttion a second problem, but what is exactly the first problem?
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  4. #4

    Thread Starter
    Member
    Join Date
    Jun 2007
    Posts
    36

    Re: How to deal with hexadecimal values

    there is no spaces separate the characters it is on the form 442A66E277
    and the first problem what's the function we use to see the character before and the character after each character....
    and the second how to see each 2 bits as one character as to see the two bits 4 & 4 as one character 44 and so on 2A 66...........
    thx for reply

  5. #5
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: How to deal with hexadecimal values

    Quote Originally Posted by king4ever101
    there is no spaces separate the characters it is on the form 442A66E277
    and the first problem what's the function we use to see the character before and the character after each character....
    and the second how to see each 2 bits as one character as to see the two bits 4 & 4 as one character 44 and so on 2A 66...........
    thx for reply
    OK no spaces then, but I assume every 2 digits represent a character? And when you say "...how to see each 2 bits as one character..." don't you mean bytes instead of bits?
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  6. #6

    Thread Starter
    Member
    Join Date
    Jun 2007
    Posts
    36

    Re: How to deal with hexadecimal values

    Quote Originally Posted by krtxmrtz
    but I assume every 2 digits represent a character? And when you say "...how to see each 2 bits as one character..." don't you mean bytes instead of bits?
    yes every 2 digits represent a character but how to make the function see that evry 2 digits represent a character (how make the function know that we deal with hex values not a asscii values an so deal with 2 digits at a time )

  7. #7
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: How to deal with hexadecimal values

    See if this is any use to you (haven't tested it, though). It takes a string that has been assigned 442A66E277 and splits it in an array of 2 characters.
    Code:
    Dim i As Integer
    Dim str As String
    Dim chr2() As String*2
    '
    str = "442A66E277"
    i = 0
    While str<>""
       ReDim Preserve chr2(i)
       chr2(i) = Left(str, 2)
       str = Mid(str, 3)
       i = i + 1
    Wend
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  8. #8
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: How to deal with hexadecimal values

    Quote Originally Posted by king4ever101
    hi
    i write a programe to convert the ascii to hexadecimal then i want to write a function to deal with these hexadecimal value>>>> for better explain here is an exapmle:
    if i have these hexadecimal value 44 2A 66 E2 F6 77
    so i want to write a function that look to first character (44) to see what the values around it (before it and after it) and replace it is value depend on that such that replace the (44) with another value like (54) and then go to the next value(2A) and see the values before and the value after >>>>>
    which mean for example if it is found that the value before the value (2A) is (44) and the value after it is (66) replace it with (77) and if it found that the value before it is (E2) and the value after is (66) replace it with (F3) and so on.....
    and second problem how to make the function to see the the values as two bit not bit by bit which mean to look to the value 44 and then to 2A and so on not to look to each bit (see 4 then 4 then 2 then A)
    i hope you understand the idea
    and sorry for my english
    Why the added complication? Why not just manipulate the original ascii values rather than working with its hex representation (the relationship ascii-hex is one-is-to-one anyway). That gives you the advantage of bit comparisons without the overhead of string manipulation.

  9. #9

    Thread Starter
    Member
    Join Date
    Jun 2007
    Posts
    36

    Re: How to deal with hexadecimal values

    Quote Originally Posted by leinad31
    Why the added complication? Why not just manipulate the original ascii values rather than working with its hex representation (the relationship ascii-hex is one-is-to-one anyway). That gives you the advantage of bit comparisons without the overhead of string manipulation.
    yes man you are right but i write a programe to send data to receiver (channel list in arabic) so the receiver has his own table that give to each character an hex value so as you know in arabic the characters are connectind to gather so each character has 3 or 4 form depend on his position in the word (in the begining of the word and in the middle and in the last) not like english has 1 shape to the character in any palce in the word...so the reciver give to each character many hex values depend in his position in the word while in computer give to each arabic character one hex value how ever it is position is, and use logical operations to view it in the right shape ...so when i send to receiver this data it is look like separate characters not connecting characters because the receiver do not use logical operations to determe the shape of the character how should it appear like computer
    so i try to write this programe that take the data and convert it to hex and then take each character to see it is position (what the character before and character after it) then change it is value depend on this way.....
    for example ( 44 25 A4) it take the 44 and see there is no character before it or there is space befor it and after it the value 25 so it change it is value to 72 (which represent to a character in the biginnig of the word) and so on........

    mr. krtxmrtz
    i will try it

  10. #10
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: How to deal with hexadecimal values

    I wasn't discussing the actual processing which I had no idea about. I was pointing out the use of strings and concept of byte manipulation.

    Code:
    Option Explicit
    
    Private Sub Form_Load()
    Dim strArr() As Byte
    Dim i As Long
    
       strArr = "Hello World"
       For i = 0 To UBound(strArr) - 1
          Debug.Print Hex(strArr(i)) & ", " & Chr(strArr(i)) & ", shifted " & IIf(i<250, Chr(i+5), Chr(i-250))
       Next
    End Sub
    Now isn't the array easier to work with than your string?
    Last edited by leinad31; Jun 27th, 2007 at 05:57 AM.

  11. #11
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: How to deal with hexadecimal values

    The text is represented properly as Unicode characters, so why not just send the Unicode string?
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  12. #12

    Thread Starter
    Member
    Join Date
    Jun 2007
    Posts
    36

    Re: How to deal with hexadecimal values

    Quote Originally Posted by Al42
    The text is represented properly as Unicode characters, so why not just send the Unicode string?
    the reveiver do not understand Unicode string when i send it it is apeear like ????????? ?? ?????

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