|
-
Feb 26th, 2003, 11:49 PM
#1
Thread Starter
Hyperactive Member
Format function doesn't work in ASP.NET?
Ok... I have a string that contains "1" ... I want to format it so that it will hold "00000001"
So I just do...
s1 = "1"
s2 = Format(s1, "00000000")
s2 now equals "00000000" ... when it should be "00000001"
This works in regular VB, but not ASP.NET .... WHY?!
-
Mar 2nd, 2003, 07:14 PM
#2
Hyperactive Member
Well, for starters, ASP.NET <> VB.
Try this:
VB Code:
Dim s1 As String = "1"
Dim s2 As String = s1.PadLeft(8, "0")
-
Oct 9th, 2003, 02:33 PM
#3
I realize this is way after the fact, but the reason this didn't evaulate correctly is due to namespace operations.
First, ASP.NET, when Language = VB IS VB.Net.
The reason this doesn't work right off is that the namespace resolution engine does not know which FORMAT to use and uses the wrong one.
Instead of
s2 = Format(s1, "00000000")
use
s2 = String.Format(s1, "00000000")
Since the Format object you were looking for is the Format object of the String class.
Need to re-register ASP.NET?
C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i
(Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)
-
Oct 9th, 2003, 04:57 PM
#4
While I'm at it, I might as well point out that the way you are doing it will be deprecated some time in the future. (Microsoft never gives estimates)
They now recommend:
s2 = Double.Parse(s1).ToString("00000000")
Need to re-register ASP.NET?
C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i
(Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|