Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Summing two text boxes on a form - HELP!
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Summing two text boxes on a form - HELP!
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. -- Hope this helps Martin Fishlock "Co-op Bank" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Link Text Boxes on Form? | Excel Discussion (Misc queries) | |||
User Form Text Boxes - Copy format of text boxes | Excel Discussion (Misc queries) | |||
Form, or seperate text boxes? | Excel Programming | |||
Summing the values in text boxes | Excel Programming | |||
How to iterate through all Text Boxes on a Form? | Excel Programming |