Click to See Complete Forum and Search --> : Rounding numbers in VB6


daftness101
07-04-2002, 03:20 PM
Hello. I'm having trouble with a program that I have to write for my computer concepts class that's due next month, when we actually cover VB. I'm not asking anyone to do my homework for me, since I've got everything I need done. The program does what it's supposed to do, but I can't figure out how to make the currency display in the textbox with only 2 numbers after the decimal instead of 4. Anyone have a good idea on how to do this?

Here's what I have which is working fine:

Private Sub cmdCalculate_Click()
Dim cBillAmt@, cTipAmt@
Dim sPercent!

cBillAmt@ = CCur(txtAmount.Text)
sPercent! = CSng(txtPercentage.Text)
cTipAmt@ = cBillAmt@ * sPercent!
txtTipAmt.Text = "$" & CStr(cTipAmt@)
End Sub


Thanks in advance.

-Daft

hu flung dung
07-04-2002, 04:10 PM
FormatCurrency()

df
07-05-2002, 03:32 AM
help->index search for "format" ??

daftness101
07-05-2002, 10:55 AM
Thanks guys. I'll look that up. I wish the book I'm reading would've covered that when it covered the different data types. Oh well, nothing's perfect. Thanks again.

-Daft

daftness101
07-05-2002, 10:58 AM
Well, I guess it would help if I had something other than the Working Model Edition. I just tried checking it out and it's telling me there's no help in the Working Model Edition. Well, no one ever said Microsoft was a user-friendly company. Oh well, I'll just wait until Monday when I have class to look it up. Thanks.

-Daft

df
07-05-2002, 11:33 AM
everyone has access to msdn.microsoft.com

search for the format command, its very flexible.

vb6 online documentation
http://msdn.microsoft.com/library/default.asp?URL=/library/devprods/vs6/vbasic/vbcon98/vbstartpage.htm

vb6 format command
http://msdn.microsoft.com/library/en-us/vbenlr98/html/vafctFormat.asp

daftness101
07-06-2002, 09:22 PM
Thanks for the links df, I'm checking them out right now. I need to remember that there's MSDN...I just don't like searching MSDN, but that's just me.

-Daft