Solved

I need to convert a string into a string of decimals

Posted on 2016-09-29
8
61 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.
0
Comment
Question by:CRB1609
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 50

Expert Comment

by:Rgonzo1971
ID: 41823051
Hi,

Could you be more precise?

Regards
0
 
LVL 50

Expert Comment

by:Gustav Brock
ID: 41823055
Yes, many can help.
But your question is more like a guessing contest - nothing to work with.

/gustav
0
 
LVL 16

Expert Comment

by:John Tsioumpris
ID: 41823088
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
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

Author Comment

by:CRB1609
ID: 41823090
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.
0
 
LVL 16

Accepted Solution

by:
John Tsioumpris earned 500 total points
ID: 41823112
if you change my above code to -30 instead of -50...it produces a rather nicely
448174800253797586740219272227 which is even,,,,
But in order to be safe and cover everything you should provide your own Mappings like :
A -->50
B -->62
C --77
 1 -->37
space -->98
I think this covers your needs...
0
 
LVL 13

Expert Comment

by:akb
ID: 41823368
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.
0
 

Author Comment

by:CRB1609
ID: 41824530
akb,
Thanks for the comment but I need a result that is numbers only.
0
 

Author Closing Comment

by:CRB1609
ID: 41824533
Thanks, John.  Just what I needed.

Clive
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question