Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Place value on a number 1

Status
Not open for further replies.

TheCandyman

Technical User
Sep 9, 2002
761
US
I have been trying to remember if there is a way to quickly get the place values for a number. Say if i had "157" a way to grab the 1, 5, and 7 into separate values. It seems there should be a quick way for this, but i can't remember it.
 
Not sure of a really good way to do this but this might give you an idea of one way to approach it. You'll obviously have to manipulate it to get what you need/want but hopefully it will inspire some you or others to something better (psuedo-code)...
Code:
For i = 1 To Len(strSource)
  strTemp = Mid(strSource, i, 1)
  Select Case i
    Case 1
      response.write strTemp & " is the ones digit.<br>"
    Case 2
      response.write strTemp & " is the tens digit.<br>"
    Case 3
      response.write strTemp & " is the hundreds digit.<br>"
    [COLOR=green]'Continue however far you want to go.[/color]
Next

------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
 
Thx Chopstik,

Just needed a push, i didn't think about a for loop. I got it working using that and here is what i did. Just FYI

Code:
For x = 1 to Len(Trim(MyValue))
     Response.Write mid(MyValue,x,1)
     MyArray(x) = mid(MyValue,x,1)
Next
Thought tossing it into an array would be easy to pull it back out of whenever i needed.
 
Good enough. Glad that it gave you something you could work with. [thumbsup]

------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top