Solved

reversing numbers

Posted on 2006-11-09
9
563 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
[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
  • 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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
 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
Adding Row and Cell on a table 14 32
alert(innerHTML); 8 44
ASP and Looping Thru a XML Document 4 47
Adding 1 the value of input "text" every 3 seconds 5 48
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…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

738 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