Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Convert 1 to 01
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

kolucoms6
Average Member

845 Posts

Posted - 06 May 2007 :  16:00:39  Show Profile

How to convert "1" to "01" in ASP ?

ILLHILL
Junior Member

Netherlands
341 Posts

Posted - 06 May 2007 :  17:07:59  Show Profile
Depends on what you mean exactly.

If you mean replace all the times the number "1" is in a string then it's like this:

replace(string, "1", "01")

Please be more specific though cause you might mean something totally different.

Greets, Dominic

CLPPR.com - All The News Only Seconds Away
Go to Top of Page

kolucoms6
Average Member

845 Posts

Posted - 06 May 2007 :  17:11:30  Show Profile

I want to convert any number to 2 digits...

Like If I am extracting day as 9 , I want to convert it to 09 and if its 14 , then leave it as 14.
Go to Top of Page

ILLHILL
Junior Member

Netherlands
341 Posts

Posted - 06 May 2007 :  17:19:24  Show Profile
Well, than the string you are pulling the data from should look something like:

StringName = Replace(StringName," 1 ", " 01 ")
StringName = Replace(StringName," 2 ", " 02 ")
StringName = Replace(StringName," 3 ", " 03 ")
StringName = Replace(StringName," 4 ", " 04 ")
StringName = Replace(StringName," 5 ", " 05 ")
StringName = Replace(StringName," 6 ", " 06 ")
StringName = Replace(StringName," 7 ", " 07 ")
StringName = Replace(StringName," 8 ", " 08 ")
StringName = Replace(StringName," 9 ", " 09 ")

I have left spaces, simply so 4 becomes 04 but 14 does not become 0104.

Greets, Dominic

CLPPR.com - All The News Only Seconds Away
Go to Top of Page

kolucoms6
Average Member

845 Posts

Posted - 06 May 2007 :  17:23:59  Show Profile

Isnt there anything like Format ("1","00") to get 01 as result ?

I believe something like exists in VB...
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 06 May 2007 :  21:00:39  Show Profile  Visit AnonJr's Homepage
Maybe this will help? http://www.w3schools.com/vbscript/func_formatnumber.asp (you'll have to copy/past the link - the filter is removing the "vbscript" from the url....)

www.w3schools.com has a good reference page for VBScript - in particular a good function reference page.
Go to Top of Page

kolucoms6
Average Member

845 Posts

Posted - 07 May 2007 :  02:00:01  Show Profile
I checked the formtnumber function but didnt find any proper reference to convert any single digit to double digit

Edited by - kolucoms6 on 07 May 2007 08:17:40
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 07 May 2007 :  08:57:38  Show Profile  Visit AnonJr's Homepage
Then the only other options I can think of is to either use ILLHILL's code above or delve into regular expressions. Remember, VBScript is a sub-set of VB. It doesn't have all the functions that VB has.
Go to Top of Page

cripto9t
Average Member

USA
881 Posts

Posted - 07 May 2007 :  08:59:39  Show Profile
In "inc_func_common" used to format dates
function doublenum(fNum)
	if fNum > 9 then 
		doublenum = fNum 
	else 
		doublenum = "0" & fNum
	end if
end function


doublenum("10") = "10"
doublenum("1") = "01"

    _-/Cripto9t\-_
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 07 May 2007 :  09:05:59  Show Profile  Visit AnonJr's Homepage
Well there's that too.
Go to Top of Page

cripto9t
Average Member

USA
881 Posts

Posted - 07 May 2007 :  09:18:15  Show Profile

    _-/Cripto9t\-_
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.3 seconds. Powered By: Snitz Forums 2000 Version 3.4.07