October 30, 2025, 05:18:54 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Floating Dollar Sign

Started by billhsln, November 16, 2011, 09:33:44 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

billhsln

I looked at USING, but there does not seem to be a way to do a floating dollar sign.  What I want is:

value = 500, I get bbbb$500, where b = blanks, so value = 1000, I get bb$1,000.

Thanks,
Bill
When all else fails, get a bigger hammer.

Copex

Justification

To left justify the output in the field use a minus sign (-) as a leading character.


PRINT USING("-#### -####", 55, 88)

-
I really should learn how to use a spell checker! though im not sure how it will help someone who can not spell?
-
Except where otherwise noted, content Posted By Copex is
licensed under a Creative Commons Attribution 3.0 License

http://creativecommons.org/licenses/by/3.0/

LarryMc

PRINT USING("$#### $####", 55, 88)
will float the $ to the left
just make sue you have enough # for your max number
you can also put commas in for thousands,etc..

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Bruce Peaslee

There was a bug in Using() that I don't think Paul ever fixed. Some numbers do not line up properly in, say, a list box.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

billhsln

Code I am using:

t1 = USING("$#####,###",boxsel)

Output it gives me:

$       1 for 1
$  1,000 for 1000

What I want is $1 and $1,000.

Bill
When all else fails, get a bigger hammer.

Bruce Peaslee

I use this:


Sub AmountToDollars(float fAmount), string
'_________________________________________________________________________________________________________________
'
'    Purpose: take a float and return a currency string
' Parameters: the amount
'    Returns: the string
'       Notes: there is curently an EBasic bug is Using() which misaligns output that has commas
'
   Def result as string
   Select true
       Case fAmount < 1000
result = Using("%f$#,#########", fAmount)
       Case fAmount < 1000000
result = Using("%f$#,########",  fAmount)
       Default
result = Using("%f$#,#######",   fAmount)
       EndSelect

   Return result
EndSub

Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

billhsln

The following does pretty close to what I was looking for, just need to check length and add blanks in front:

string rtn ="Z"
int i=15000
rtn = "$" + ltrim$(Using("###,######", i))
print rtn

Bill
When all else fails, get a bigger hammer.