IonicWind Software

IWBasic => General Questions => Topic started by: billhsln on November 16, 2011, 09:33:44 PM

Title: Floating Dollar Sign
Post by: billhsln on November 16, 2011, 09:33:44 PM
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
Title: Re: Floating Dollar Sign
Post by: Copex on November 17, 2011, 01:57:22 AM
Justification

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


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

Title: Re: Floating Dollar Sign
Post by: LarryMc on November 17, 2011, 04:56:49 AM
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
Title: Re: Floating Dollar Sign
Post by: Bruce Peaslee on November 17, 2011, 10:27:06 AM
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.
Title: Re: Floating Dollar Sign
Post by: billhsln on November 17, 2011, 11:15:38 AM
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
Title: Re: Floating Dollar Sign
Post by: Bruce Peaslee on November 17, 2011, 12:01:19 PM
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

Title: Re: Floating Dollar Sign
Post by: billhsln on November 17, 2011, 06:19:02 PM
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