Digits$
Result$ = Digits$(InputValue, Digits)
 
Parameters:

    InputValue = The Value you wish to format to a zero padded string
    Digits = The number of digits the resulting string should have
Returns:

    Result$ = the value converted to a padded string
 

      The Digits$() function is similar to the str$() function, except Digits$ will zero pad the resulting string for us. So we can be sure the resulting string will be a fixed length.



FACTS:


      * This is handy when displaying/formatting numeric values to the screen, such as game scores and life counters.

     * If your value overflows the number of selected Digits to return, those decimal places will be lost.

      * Does not support negative values.




Mini Tutorial:


Display the numbers 1 to 10 zero padded to 4 digits.

  
; Make a loop to count from 1 to 10
  For lp =1 To 10
   ; Display the loop counter, padding each value to 4 diigts..
     Print Digits$(lp,4)
  Next
  
; Display the Screen and wait for the user to press a key
  Sync
  WaitKey
  


This example would output.

  
  0001
  0002
  0003
  0004
  0005
  0006
  0007
  0008
  0009
  0010
  

 
Related Info: Bin$ | Hex$ | Integer | Str$ | Val :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com