We help IT Professionals succeed at work.

I need to convert a string into a string of decimals

Clive Beaton
Clive Beaton asked
on
167 Views
Last Modified: 2016-10-01
I need to convert a string into a string of decimals, 2 decimals per original character.  Alternatively to convert to a hex looking format 1-9 A-F.

Can anyone help?

Thanks in advance.
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2016

Commented:
Hi,

Could you be more precise?

Regards
CERTIFIED EXPERT
Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
Yes, many can help.
But your question is more like a guessing contest - nothing to work with.

/gustav
John TsioumprisSoftware & Systems Engineer
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
I guess what you need is to match a char to a pair of numbers (e.g for encryption)
Public Function TextToPair(InputString As String) As String
Dim tmpOutput As String
Dim strLen As Integer
Dim counter As Integer
strLen = Len(InputString)
For counter = 1 To strLen
tmpOutput = tmpOutput & Format(Asc(Mid(InputString, counter, 1)) - 50, "00")
Next
Debug.Print tmpOutput
TextToPair = tmpOutput
End Function

Open in new window

To test it
TextToPair("ALPHATest")

Open in new window

produces :
152630221534516566

Open in new window

From there you can play many tricks like inverting the output...addng or substracting a value (eg. +10)...the minus 50 is to catch the letters above 99...so "A" instead of 65 becomes 15...you can also define your own mappings
Clive BeatonAccess Developer

Author

Commented:
If I have a string like "John Smith 1949" I want to resolve each character to 2 digits 0-9 so that I end up with a string that might look something like "156042318542789582652545657528".

The purpose is to create a product registration key from the user name and unique member number.

The user registers the product by sending me the user name and number.

My registration program creates the key and sends it back.

The user enters the key into the registration screen in the program, which creates the same key from the information in the prgram, using the same logic.  If thekeys  match the program is registered.

Hope that helps.
Software & Systems Engineer
CERTIFIED EXPERT
Distinguished Expert 2019
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
akb
CERTIFIED EXPERT

Commented:
Really no point to doing that. That would be so easy to crack that you may as well not even bother. You really need to encrypt the key.
Clive BeatonAccess Developer

Author

Commented:
akb,
Thanks for the comment but I need a result that is numbers only.
Clive BeatonAccess Developer

Author

Commented:
Thanks, John.  Just what I needed.

Clive
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.