[Help]Do not convert to hex!

Posts 1–7 of 7 · Page 1 of 1
[Help]Do not convert to hex!
I need a little fix for the hex function right now.
Here is an example of what im trying to do.

For example: If my string was this:
[Hello][Bye]CakeBuster[Dead]

How do i only convert the string CakeBuster to hex
So anything in between "[" and "]" will not be converted into hex.

Hex Function i am currently using:
Code:
   Dim hex As String = Nothing
        For i As Integer = 0 To text.Length - 1
            hex &= Asc(text.Substring(i, 1)).ToString("x").ToUpper
        Next
        Return hex
    End Function
Quote Originally Posted by ppl2pass View Post
I need a little fix for the hex function right now.
Here is an example of what im trying to do.

For example: If my string was this:
[Hello][Bye]CakeBuster[Dead]

How do i only convert the string CakeBuster to hex
So anything in between "[" and "]" will not be converted into hex.

Hex Function i am currently using:
Code:
   Dim hex As String = Nothing
        For i As Integer = 0 To text.Length - 1
            hex &= Asc(text.Substring(i, 1)).ToString("x").ToUpper
        Next
        Return hex
    End Function
Here buddy

[php]Dim Source As String = "[Hello][Bye]CakeBuster[Dead]"
Dim _1 As Integer = Source.LastIndexOf("[")
Dim Ex1 As String = Mid(Source, 1, _1)
Dim _2 As Integer = Ex1.LastIndexOf("]") + 2
Dim FinalExtraction As String = Mid(Ex1, _2)
Dim hex As String = Nothing
For i As Integer = 0 To FinalExtraction.Length - 1
hex &= Asc(FinalExtraction.Substring(i, 1)).ToString("x").ToUpper
Next
MsgBox(hex)[/php]

Hope this helps
btw can you give me a little explanation of your code.
Quote Originally Posted by ppl2pass View Post
btw can you give me a little explanation of your code.
No problem !!

Code:
  Dim Source As String = "[Hello][Bye]CakeBuster[Dead]"
        Dim _1 As Integer = Source.LastIndexOf("[")
        Dim Ex1 As String = Mid(Source, 1, _1)
        Dim _2 As Integer = Ex1.LastIndexOf("]") + 2
        Dim FinalExtraction As String = Mid(Ex1, _2)
Dim _1 As Integer = Source.LastIndexOf("[")

This line gets the index (number) for last "[".

Dim Ex1 As String = Mid(Source, 1, _1)

This will store the string up to last "[" but not after that.

Dim _2 As Integer = Ex1.LastIndexOf("]") + 2

Similarly this will get the last index of "]" in the new string which is Ex1 now !!

Dim FinalExtraction As String = Mid(Ex1, _2)

Finally, extract the word you need by starting the string from "]".

Its a bit tricky, but I think you got it

@NextGen: Oh ok, no problem at all. Thnx for reminding me. I'll post it in a few minutes
thanks man. +rep.
Looks good, thanks for sharing, feel fee to post it in the snippets vault though, that is what it is there for

Instead of creating threads add them to the snippets vault
oo thanks man. i get this. +rep
Posts 1–7 of 7 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Talk with us