[thelist] ASP: getting double digits

Matt Warden Matt Warden" <mwarden at odyssey-design.com
Thu, 20 Jan 2000 17:25:35 -0500


> varNow = Now
> strMonth = MakeCorrect(CStr(Month(varNow)), 2)
> strYear = MakeCorrect(Cstr(Year(varNow)), 4)
>
> Function MakeCorrect(strString, ExpectedLength)
>     If Len(strString) = ExpectedLength THEN strString = "0" &
strString

AHHHH!!!! Well, I was just going to fix this one line, but the whole
function needs rewriting.

Function MakeCorrect(strString, ExpectedLength)
    StringLength = len(strString)
    IF StringLength < ExpectedLength THEN
        FOR i = 1 to (ExpectedLength-StringLength)
            strString = strString & "0"
        NEXT
    END IF
    MakeCorrect = strString
END Function

Ok. I feel like I just learned VBScript yesterday :)

<mumble>Damn.... stupid.... mistake... piece of...</mumble>

-Matt