|
-
Jun 17th, 2001, 02:01 PM
#1
Octal String
I have a database entry the is in a octal string. So it takes a text string and converts it into a hex.
Can someone post a code snipit to convert "test this 123" to hex and back?
Thanks
-
Jun 17th, 2001, 02:17 PM
#2
_______
<?>
Code:
Private Sub Command1_Click()
x = "test this 123"
MsgBox "test this " & Hex(Right(x, 3))
MsgBox "test this " & CDbl(&H7B) 'hex uses &H before number
'oct uses &0
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Jun 17th, 2001, 02:26 PM
#3
Well...
I need to encode and decode the text string part too.
-
Jun 17th, 2001, 03:11 PM
#4
_______
<?>
Well, it's beyond me....then again a lot of things are.
Hex Function:
Returns a String representing the hexadecimal value of a number.
Oct Fucntion:
Returns a Variant (String) representing the octal value of a number.
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Jun 17th, 2001, 03:25 PM
#5
Well...
I need to encode and decode the text string part too.
-
Jun 17th, 2001, 06:11 PM
#6
_______
<?>
Well
thanks for the lesson in hex....
Code:
Private Sub Command1_Click()
Dim x As String, i As Integer, y As String
x = "test this 123"
For i = 1 To Len(x)
y = y & Hex(Asc(Mid(x, i, 1)))
Next i
MsgBox y
MsgBox UnHex(y)
End Sub
Public Function UnHex(sR As String) As String
Dim sTemp As String
Dim i As Integer, iKey As Integer
On Error Resume Next 'Trap for error
On Error GoTo 0 'Turn off error trapping
For i = 1 To Len(sR) Step 2 'Loop through each char in the given string
sTemp = sTemp & Chr$(Val("&H" & Mid$(sR, i, 2) & "&"))
Next i
UnHex = Trim$(sTemp) 'Return the string
End Function
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Jun 18th, 2001, 01:46 AM
#7
Thanks
That's what I needed.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|