|
-
May 11th, 2007, 04:18 PM
#1
Thread Starter
Fanatic Member
[RESOLVED]ID number generator
Well I am building an ID number generator. How can I loop through a string and find the ascii value of each character. Example
String Mxjerrett
Converted 77120106101114114101116116
Last edited by Mxjerrett; May 11th, 2007 at 06:18 PM.
If a post has been helpful please rate it. 
If your question has been answered, pull down the tread tools and mark it as resolved.
-
May 11th, 2007, 04:39 PM
#2
Fanatic Member
Re: ID number generator
Code:
Dim i As Integer
Dim strID As String
Dim strName As String
strName = "Mxjerrett"
strID = ""
For i = 1 to Len(strName)
strID = strID & Asc(Mid(strName, i, 1))
Next
r0ach™
Don't forget to rate the post
-
May 11th, 2007, 04:44 PM
#3
Addicted Member
Re: ID number generator
I think he wants to convert "77120106101114114101116116" back to "Mxjerrett"
That code looks like it will do what he already did. But, not sure how you would convert that back without having some sort of seperator between each number that is a letter.
Looking at the end of the converted string, how would you say "Convert 16, then 116" or "Convert 61, then 16"
You could have it insert something between each converted letter, so it would be like.. "77.120.106...." but that would be easy to reverse (though not like what you have now will stump anyone )
- If you found my post to be helpful, please rate me.

-
May 11th, 2007, 04:59 PM
#4
Fanatic Member
Re: ID number generator
Well he said he's generating an ID number. He said he wanted to loop through a string and find the ascii value for each char.
What I would have done with your suggested problem is this:
Code:
Dim i As Integer
Dim strID As String
Dim strName As String
Dim strAscii As String
strName = "Mxjerrett"
strID = ""
For i = 1 to Len(strName)
strAscii = Asc(Mid(strName, i, 1))
strID = strID & Len(strAscii) & strAscii
Next
The ID would be "27731203106310131143114310131163116"
This will be easy to convert back to a name, but because the 3's look like delimiters it's still not perfect. From there I'd chop it into groups of 2 and convert it to 2 char hex (6 = 06, F = 0F) leaving "1B490C030A3F0A0D0B2B0B2B0A0D0B3F0B06". Simple, I know. And nowhere near foolproof. But easy to convert back to a name, and not obvious.
Here's some quick code:
Code:
Dim i As Integer
Dim strID As String
Dim strTmp As String
Dim strHex As String
Dim strName As String
Dim strAscii As String
strName = "Mxjerrett"
strID = ""
For i = 1 To Len(strName)
strAscii = Asc(Mid(strName, i, 1))
strID = strID & Len(strAscii) & strAscii
Next
'strID = 27731203106310131143114310131163116
strTmp = ""
For i = 1 To Len(strID) Step 2
strHex = Right("00" & Hex(Val(Mid(strID, i, 2))), 2)
strTmp = strTmp & strHex
Next
'strTmp = 1B490C030A3F0A0D0B2B0B2B0A0D0B3F0B06
r0ach™
Don't forget to rate the post
-
May 11th, 2007, 05:44 PM
#5
Thread Starter
Fanatic Member
Re: ID number generator
Your code works perfectly, but now I need help deconverting it. I have the program putting - in between each character, but now I need to try to convert it back to characters. Ex:
My ID: 77-88-74-69-82-82-69-84-84
My Username (yes I know it is caps): MXJERRETT
If a post has been helpful please rate it. 
If your question has been answered, pull down the tread tools and mark it as resolved.
-
May 11th, 2007, 06:12 PM
#6
Thread Starter
Fanatic Member
Re: ID number generator
Nevermind guys, I wrote my own code that seems to work 100% perfectly. Here is the code in case you guys wanted to know:
Code:
Dim strAscii, strID, strName As String
strID = Replace(txtID, "-", "")
For i = 1 To Len(strID) / 2
strAscii = Chr(Right(Left(strID, i * 2), 2))
strName = strName & strAscii
Next
txtName = strName
If a post has been helpful please rate it. 
If your question has been answered, pull down the tread tools and mark it as resolved.
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
|