Db Value

Results 1 to 2 of 2

Thread: Db Value

  1. #1
    Join Date
    Dec 1969

    Default Db Value

    I have a value in a numeric db field that is: 051117. When I call it on my asp page, it gives me: 51117. How can I keep the zero that is in from of the 5. thanks

  2. #2
    Join Date
    Dec 1969

    Default RE: Db Value

    If you always want the value to be the same length you could do something like the following. There might be a better approach. Anyone?<BR><BR>function zeroPad(pVal, maxLen)<BR>&#039; pVal = value to be padded<BR>&#039; maxLen = desired length of the padded string<BR><BR> dim numChars<BR> <BR> &#039; figure out how many extra zeros to add to pVal<BR> numChars = maxLen - len(cstr(pVal))<BR><BR> &#039; the string(number, character) function returns a given string repeated &#060;number&#062; times<BR> zeroPad = string(numChars, "0") & cstr(pval)<BR> <BR>end function<BR><BR>&#039; test it out<BR>response.write zeroPad(51117, 6)

Posting Permissions

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