Solved

reversing numbers

Posted on 2006-11-09
9
525 Views
Last Modified: 2008-02-01
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
Comment
Question by:ramma
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 43

Expert Comment

by:TimCottee
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

by:ramma
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

by:TimCottee
ID: 17905946
TimCottee,

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


Tim
0
 
LVL 20

Expert Comment

by:jitganguly
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:ramma
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

by:B_Dorsey
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

by:
B_Dorsey earned 100 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

by:Anthony Perkins
ID: 17919658
0
 

Author Comment

by:ramma
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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 information …
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/…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now