Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replace characters and numbers with ASCII

Status
Not open for further replies.

Crystalguru

Technical User
Oct 4, 2001
303
US
Crystal Version 8.5
MS SQL 2000

I need to convert the following id code to ascii numbers. A-Z = 65-90,
0-9 = 48-57

ID Code
123BDC455
040CGQ791

The code will always be 3 numbers, 2 chars, 3 numbers.

I need them to convert to:
ID Code conversion
123BDC455 495051666867525353
040CGQ791 485248677181555748

I am trying to use the following:
right(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace
(mid(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace
(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace
(idcode,"A", "65"),"B","66"),"C","67"),"D","68"),"E","69")
,"F","70"),"G","71"),"H","72"),"I","73"),"J","74"),"K","75"),"L","76"),"M","77"),"N","78"),"O","79"),"P","80"),"Q","81"),"R","82"),"S","83"),"T","84"),"U","85"),"V","86"),"W","87"),"X","88"),"Y","89"),"Z","90"),6)
,"0","48"),"1","49"),"2","50"),"3","51"),"4","52"),"5","53"),"6","54"),"7","55"),"8","56"),"9","57"),6);

The return results are coming back as:
743590
457425

I am missing something here.

The above example code is only for the right and mid. I needed to start small.

Thanks




 
This is wrong "The code will always be 3 numbers, 2 chars, 3 numbers.", your examples show 3 numbers, 3 CHARS (not 2), and 3 numbers.

Anyway, that's the long way home:

stringvar InChar:= "123BDC455"; //use your {table.field}
stringvar OutChar:="";
numbervar counter;
for Counter := 1 to len(trim(InChar)) do(
OutChar:=OutChar+totext(asc(mid(InChar,counter,1)),0,"")
);
OutChar

-k
 
Yes, you are correct in saying that the code is 3 numbers, 3 characters, 3 numbers...typing faster than I can think.

Thanks for the formula. It did exactly what I was looking for. I totally forgot about the asc function. And I just finished doing another report with it. Once again, the brain does a screeching halt.

Thanks so much for making up where my brain left off.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top