Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cacul format problem 1

Status
Not open for further replies.

Xenocide

Programmer
Jan 20, 2005
76
CA
I have two textbox

They both have almost the same code as each other as well as the 2 table (Table807, Table850) they take their info from

When I do the calcul, the first box does it without probem, the second one.. instead of add the number put it one to next other.. meaning it prally take it as text.

The listbox they take their info from both have the same select.

At first I though it could the Table807 causing the trouble
But if I pick up Table807 with the first textbox the calcul go without a problem.. if I take it with Table807 too.

As soon as it's the second textbox.. no matter which Table is taken it doesn't work

Here's a part of the code that has something to do with those 2 textbox.

Private Sub cmd1_Click()
On Error GoTo Err_cmd1_Click

Dim strSQL1 As String
Dim strSQL2 As String

txt1.Value = lst1.Column(3) - txt3.Value
txt2.Value = lst2.Column(3) + txt3.Value


can you help me?
 
there's no problem if I do a substraction on txt2 or if I switch everything around.

As soon as I do the addition the problem appear.. and on both text field.
 
Some of the elements are probably, as you say, either in fact text, or interpreted as text, not numeric, then a concatenation occurs, not math. What happens if you use the Val function on the controls?

[tt]txt2.Value = val(lst2.Column(3)) + val(txt3.Value)[/tt]

Roy-Vidar
 
work perfectly =^_^+ thanks a lot

I did also using a Long variable where in which I did all the calcul and the assigned the variable to my txt2

But yur way's better since I don'T have to add more line to my code
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top