Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 578
  • Last Modified:

reversing numbers

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
ramma
Asked:
ramma
  • 3
  • 2
  • 2
  • +2
1 Solution
 
TimCotteeHead of Software ServicesCommented:
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
 
rammaAuthor Commented:
Tim am sorry but how can replace . with space?
instead 5.4.3.2.1 it should be 5 4 3 2 1  ?
0
 
TimCotteeHead of Software ServicesCommented:
TimCottee,

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


Tim
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
jitgangulyCommented:
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
 
rammaAuthor Commented:
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
 
B_DorseyCommented:
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
 
B_DorseyCommented:
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
 
Anthony PerkinsCommented:
0
 
rammaAuthor Commented:
No it was not duplicated .. i just wanted to do it in SQL or Stored Procedure as i mentiioned there.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now