filling a var with characters

Results 1 to 2 of 2

Thread: filling a var with characters

  1. #1
    Join Date
    Dec 1969

    Default filling a var with characters

    Hi,<BR>I got a variable with a value whitch can be "9" or "09"<BR>I have this code to have it always started with a zero:<BR><BR>If Len(minuts)=1 Then <BR> minuts = "0" & minuts<BR>End If<BR>Response.Write minuts<BR><BR>Can&#039;t this be done in another, easy way?<BR>like you got in c++ the functions setfill and setw for it..<BR><BR>Greetings, <BR>Peter

  2. #2
    Join Date
    Dec 1969

    Default How much easier... you want?!<BR><BR>Ok, put it in a function:<BR>Function PadNumberToString(intNumberToPad, intCharacters)<BR> intNumberToPad = CStr(intNumberToPad)<BR> if Len(intNumberToPad) &#062;= intCharacters then<BR> PadNumberToString = intNumberToPad<BR> Exit Function<BR> end if<BR> do while Len(intNumberToPad) &#060; intCharacters)<BR> intNumberToPad = "0" & intNumberToPad<BR> loop<BR> PadNumberToString = intNumberToPad<BR>End Function<BR><BR>But you&#039;re gonna end up with the same thing...<BR><BR>Craig.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts