Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

reversing numbers

Posted on 2006-11-09
9
Medium Priority
?
572 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 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

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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

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…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

722 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