calculations using VB

  • Thread starter Thread starter michael goodall
  • Start date Start date
M

michael goodall

i am trying to add the values in 3 text boxes (numbers in each) but it
is just combining them, ie i want 3+4+7, but access returns 347.
the code i am using is:
Me.Total_amount_of_ram.Value = Me.quantity_of_ram__slot_1_.Value +
Me.quantity_of_ram__slot_2_.Value + Me.quantity_of_ram__slot_3_.Value

has anyone any tips or pointers that could help me?
many thanks michael
 
Adding text boxes can yield unexpected results as the value is actually a
variant. It is best to convert the values to a numeric data type first as
in:
Me.Total_amount_of_ram.Value = CDbl(Me.quantity_of_ram__slot_1_.Value) +
CDbl(Me.quantity_of_ram__slot_2_.Value) +
CDbl(Me.quantity_of_ram__slot_3_.Value)
 

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

Back
Top