Results 1 to 8 of 8

Thread: [RESOLVED] Remove Delimiter Question

  1. #1

    Thread Starter
    Hyperactive Member wiccaan's Avatar
    Join Date
    Apr 2004
    Location
    127.0.0.1
    Posts
    475

    Resolved [RESOLVED] Remove Delimiter Question

    Hey guys got a question on removing a delimiter on a random sized string. The string is a persons name, their respective hex numbers, with the number 0 seperating each hex value. Such as:

    5706906306306106106E

    Would equal Wiccaan, with 0's seperating each hex combo.

    I need to remove the 0, or change it with a " " (space) instead of having the 0's there. I ask this cause I have a file of names in hex with this delemiter and I need to convert it from the hex to regular letters.

    I can make the ASCII function to convert the hex to ascii, I just cant figure out how to start a function to remove the 0's because hex uses 0's...

    Thanks for the help in advance.
    If my post was helpful please rate it

  2. #2
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: Remove Delimiter Question

    Maybe with Replace?

    VB Code:
    1. MyString = Replace (MyString, "0", " ")

    Or you could use directly Split(MyString, "0"), that will return an array with Hex values (in string format).
    Last edited by jcis; Jan 7th, 2006 at 05:29 PM.

  3. #3
    Fanatic Member
    Join Date
    Dec 2002
    Location
    North Carolina
    Posts
    734

    Re: Remove Delimiter Question

    jcis: That method would not work due to the fact that some hex values can start with a zero. For example:
    01 0A 0B, and if you string those together with a delimiter of zero you get
    0100A00B

    wiccaan: Can you just change the delimiter to something easy to get out such as ";"?


    "X-mas is 24.Desember you English morons.." - NoteMe

  4. #4

    Thread Starter
    Hyperactive Member wiccaan's Avatar
    Join Date
    Apr 2004
    Location
    127.0.0.1
    Posts
    475

    Re: Remove Delimiter Question

    Quote Originally Posted by jcis
    Maybe with Replace?

    VB Code:
    1. MyString = Replace (MyString, "0", " ")

    Or you could use directly Split(MyString, "0"), that will return an array with Hex values (in string format).

    For some reason I went brain dead on that and keep figuring that the letters had 0's in them as well. Sorry about my mistake. Thanks.

    Quote Originally Posted by dsheller
    jcis: That method would not work due to the fact that some hex values can start with a zero. For example:
    01 0A 0B, and if you string those together with a delimiter of zero you get
    0100A00B

    wiccaan: Can you just change the delimiter to something easy to get out such as ";"?
    Cant, its not my file, Im just converting it to the actuall names. Like the file is updated probably weekly almost from someone else. So Im just going with what he is using himself.
    If my post was helpful please rate it

  5. #5
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: Remove Delimiter Question

    Quote Originally Posted by dsheller
    jcis: That method would not work due to the fact that some hex values can start with a zero. For example:
    01 0A 0B, and if you string those together with a delimiter of zero you get
    0100A00B

    wiccaan: Can you just change the delimiter to something easy to get out such as ";"?
    Ok, but no program will be able to guess what kind of "0" it is (if delimiter or part of a Hex), so, What about using another character as delimiter?

  6. #6
    Fanatic Member
    Join Date
    Dec 2002
    Location
    North Carolina
    Posts
    734

    Re: Remove Delimiter Question

    VB Code:
    1. Private Sub Form_Load()
    2.     Dim hx As String
    3.     hx = "5706906306306106106E"
    4.    
    5.     Do Until Len(hx) = 0
    6.         MsgBox ReadTwo(hx)
    7.         hx = ChopTwo(hx)
    8.         If Len(hx) >= 1 Then
    9.             hx = ChopDelim(hx)
    10.         End If
    11.     Loop
    12.    
    13. End Sub
    14.  
    15. Private Function ReadTwo(strString As String) As String
    16.     ReadTwo = Left(strString, 2)
    17. End Function
    18.  
    19. Private Function ChopTwo(strString As String) As String
    20.     ChopTwo = Right(strString, Len(strString) - 2)
    21. End Function
    22.  
    23. Private Function ChopDelim(strString As String) As String
    24.     ChopDelim = Right(strString, Len(strString) - 1)
    25. End Function

    Alright, well as long as each hex char is always two digits that should work.


    "X-mas is 24.Desember you English morons.." - NoteMe

  7. #7
    Fanatic Member vbasicgirl's Avatar
    Join Date
    Jan 2004
    Location
    Manchester, UK
    Posts
    1,016

    Re: Remove Delimiter Question

    because the hex value will be no more than 2 characters then we can do a for loop with a step of 3 then convert within the loop
    VB Code:
    1. Dim str1 As String, i As Long, str2 As String
    2.  
    3. str1 = "5706906306306106106E"
    4.  
    5. For i = 1 To Len(str1) Step 3
    6.  str2 = str2 & Chr(CLng("&H" & Mid$(str1, i, 2)))
    7. Next i
    8.  
    9. MsgBox str2

    casey.

  8. #8
    Fanatic Member
    Join Date
    Dec 2002
    Location
    North Carolina
    Posts
    734

    Re: Remove Delimiter Question

    I like vbasicgirls way of doing it better than mine, try that one.


    "X-mas is 24.Desember you English morons.." - NoteMe

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