I’ve read the documentation up and down; is there a way to set a variable to automatically insert the thousands comma separators? “Format” seems to require a set number to work.
I know in VB6, I used (for example): Cash: $" & FormatNumber(cash, 0) which would insert the commas into the right places. The number can vary greatly, it should be noted.
As I stated above, I’ve read about Format and it seems to only take set numbers in the examples i’ve seen, not variables. The ‘cash’ variables is in this case a whole Integer number, not money in my case.
I already tried to display it as Format(cash, “##,####”) and I get a syntax error.
Hmm, yep got it to work. I ended up having to dim a string, then put the formatted ‘cash’ variable into it. Then it displays fine.
I assume this code is the best way to do it?
Dim cashst as String
cashst=Format(cash, "##,###")
Label1.Text = "Cash: $" + cashst
there is no “best” way to do anything… there are BAD ways… but a comparative analysis requires TWO methods… so it is impossible to say if this “way” if “better” (or worse) than another way, without know what the “other” way is
[quote=84227:@Derek DiBenedetto]Hmm, yep got it to work. I ended up having to dim a string, then put the formatted ‘cash’ variable into it. Then it displays fine.
I assume this code is the best way to do it?
Dim cashst as String
cashst=Format(cash, "##,###")
Label1.Text = "Cash: $" + cashst[/quote]
The result of the Format function is a string, I’m assuming that you were trying to assign the formatted text to your integer ‘Cash’ variable, which would give you a syntax error.