Summing two text boxes on a form - HELP!

G

Guest

Hello,

I have a simple input form, there are 3 boxes which hold numbers. A net cost
is firstlykeyed into a text box called 'tbNet' then if the item is vatable a
'VAT @ 17.5%' checkbox is selected and this calculates 17.5% of the input
disabled text box called 'tbVAT'.

The 3rd text box 'tbGross' needs to add the other two text boxes togethor, I
keyed this bit of code as Private Sub's 'tbGross_Change' and 'tbVAT_Change'
the code I have used is 'frmCashRecd.tbGross.Value = frmCashRecdtbVAT.Value
+ frmCashRecd.tbNet.Value' but rather than sum the two values togethor (i.e.
100 + 17.50 = 120) the value in 'tbGross' is 10017.5 (i.e. it concatenates
the two togethor). Is there a bit of code I can use that will sum instead?

Please help!

Cheers
Brian, Manchester
 
G

Guest

Brian

A textbox returns a string you therefore need to convert the string to a
number to use them. If they are integers use cint or clng or if reals cdbl
or ccur depending on your preference remebering to apply the rules for the
calculation of VAT and I think it is to round down but I'm not sure. So when
you calc the VAT is should be rounded to two places
rounddown(ccur(me.tbnet.value) * VATRate,2).

Use a constant for the vat rate so that it is easy to change when they
change it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top