Solved

# reversing numbers

Posted on 2006-11-09
Medium Priority
577 Views
hi experts..
i have this a number that consists of unknown no of digits(1 or 12 ... or 12345).
i need firstly to reverse this number for example if the number is 12345 it should be converted to 54321.
also i have to put a dot between every digit so it should be 5.4.3.3.1.
Any idea?
0
Question by:ramma
• 3
• 2
• 2
• +2

LVL 43

Expert Comment

ID: 17905464
Hi ramma,

Dim mystring
Dim mynewstring
mystring="12345"
Dim intpos
for intpos = len(mystring) to 1 step -1
mynewstring = mynewstring & substring(mystring,intpos,1) & "."
next
response.write mynewstring

This should show how you can achieve this.

Tim Cottee
0

Author Comment

ID: 17905911
Tim am sorry but how can replace . with space?
instead 5.4.3.2.1 it should be 5 4 3 2 1  ?
0

LVL 43

Expert Comment

ID: 17905946
TimCottee,

>     mynewstring = mynewstring & substring(mystring,intpos,1) & " "

Tim
0

LVL 20

Expert Comment

ID: 17908270
College assigment ?

I remember one of the questions in my college was

How many direct connections does it take to connect n computers together? Suppose you have a computer in each of the 50 states in the United States; how many direct connections would you need?
0

Author Comment

ID: 17910453
Dear Tim .. I got this error in this line :

-----------------------------------------------------------------------------
mynewstring = mynewstring & substring(mystring,intpos,1) & " "
-----------------------------------------------------------------------------

This is the error message :

Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'substring'
/people/REVERSE.asp, line 15

Any Idea??
0

LVL 14

Expert Comment

ID: 17911969
ummmm doesnt StrReverse do this?

dim mystring,newstring
mystring="12345"
mystring = StrReverse(mystring)
for i = 1 to Len(mystring)
newstring = newstring & mid(mystring,i,1) & " "
next
0

LVL 14

Accepted Solution

B_Dorsey earned 400 total points
ID: 17911975
my bad, if you want to remove the last extra space, you could do this instead, i also forgot to wwrite in the last response.write

dim mystring,newstring
mystring="12345"
mystring = StrReverse(mystring)
for i = 1 to Len(mystring)
newstring = newstring & mid(mystring,i,1)
if not i = Len(mystring) then
newstring = newstring & " "
end if
next
response.write newstring
0

LVL 75

Expert Comment

ID: 17919658
0

Author Comment

ID: 17924588
No it was not duplicated .. i just wanted to do it in SQL or Stored Procedure as i mentiioned there.
0

## Featured Post

Question has a verified solution.

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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is: Â  The Exchange of informatioâ€¦
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/â€¦
Integration Management Part 2
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recovâ€¦
###### Suggested Courses
Course of the Month8 days, 9 hours left to enroll