Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old April 15th, 2005, 07:26 AM
sickmusic sickmusic is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 9 sickmusic User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 38 m 9 sec
Reputation Power: 0
format string / fixed length / prefix character

Hi,

ive got a string variable that holds numbers (Dim euNumber)

euNumber can be of any length raging from 1-6.

For presentation purpouses euNumber has to be of length 6.
If the original is less than 6 digits long then
a number of "0"'s should be added to the left side of the string

If the string is empty then
leave the string empty.

euNumber is called in using a request.form()

I have tried the following:
Quote:
euNumber=String(6-(Len(euNumber)),"0") & euNumber
If (euNumber="000000") Then
euNumber=""
End If


The above method does not work, if the string already is of length 6, it will adds a "0" in front of it still. resulting of a string length of 7

Is there an easier ay to format strings?

Can I use the FormatNumber function to do this?

Reply With Quote
  #2  
Old April 15th, 2005, 08:19 AM
Yeruhn's Avatar
Yeruhn Yeruhn is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Netherlands
Posts: 428 Yeruhn User rank is Sergeant (500 - 2000 Reputation Level)Yeruhn User rank is Sergeant (500 - 2000 Reputation Level)Yeruhn User rank is Sergeant (500 - 2000 Reputation Level)Yeruhn User rank is Sergeant (500 - 2000 Reputation Level)Yeruhn User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 16 h 35 m 27 sec
Reputation Power: 10
A nice solution is:
Code:
euNumber = right("000000" & euNumber, 6)
Comments on this post
mehere agrees: nice one ..
sickmusic agrees!

Reply With Quote
  #3  
Old April 15th, 2005, 08:42 AM
sickmusic sickmusic is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 9 sickmusic User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 38 m 9 sec
Reputation Power: 0
fantastic,

many thanks

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingCode Bank > format string / fixed length / prefix character


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway