Not to beat the dying horse, but wouldn't it have been a lot easier to just use....
Code:
FormattedString = FORMAT$(VAL(numberAsString), "#,")
Conversion tool Number One is that grey stuff between the ears!
FormattedString = FORMAT$(VAL(numberAsString), "#,")
'void WINAPI AddCommas( LPTSTR pszNumber ); Declare Sub AddCommas Lib "TakeCmd.dll" Alias "AddCommas"(zNumber as Asciiz)
DECLARE SUB AddCommas LIB "TakeCmd.dll" _ ALIAS "AddCommas" _ (BYVAL lpstr AS DWORD) FUNCTION PBMAIN () AS LONG DIM TheString AS STRING * 512 TheString = "12345678" AddCommas VARPTR(TheString) PRINT TheString END FUNCTION
TheString = UCODE$("12345678") AddCommas VARPTR(TheString) PRINT ACODE$(TheString)
#COMPILE EXE #DIM ALL 'The following comments are from the [URL="ftp://ftp.jpsoft.com/sdk/sdk.zip"]Plugin SDK[/URL] from JPSoft; 'From takecmd.h ' 'void WINAPI AddCommas( LPTSTR pszNumber ); '/* ' Insert thousands separators in pszNumber '*/ '3.3 Some functions in TakeCmd.dll manipulate the string that you pass to them ' within the buffer in which the string resides. Therefore, if the ' TakeCmd.dll function can return a longer string than is passed to it, you ' must make sure that you pass the string in a buffer that is large enough ' to provide working space and to hold the returned string if appropriate. ' An example of such a function is: ' void WINAPI AddCommas( LPTSTR pszNumber ); ' which inserts the thousands separator into the supplied number. In ' Delphi this would be declared as: ' procedure AddCommas(Arguments: PWideChar); stdcall; external 'TakeCmd.dll'; ' When this procedure adds in the thousands separator the resulting string ' will be longer than the string that you started with, and so you must ' allow room for that expansion. The size of the buffer that you need ' cannot be precisely defined, and you may need to experiment. However, as ' a guideline I would suggest a buffer of at least three times the length ' of the string that you are passing to the function. DECLARE FUNCTION AddCommas LIB "TakeCmd.dll" _ ALIAS "AddCommas" _ (lpstr AS STRING) AS STRING FUNCTION PBMAIN () AS LONG DIM TheString AS STRING * 512 TheString = "12345678" AddCommas TheString PRINT TheString END FUNCTION
AddCommas TheString
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Leave a comment: