ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   What do i wrong here (https://www.excelbanter.com/excel-programming/306711-re-what-do-i-wrong-here.html)

Dick Kusleika[_3_]

What do i wrong here
 
Alvin

Everything in a textbox is text, not numeric. The minus sign in the first
example coerces the text into numbers and you get the right answer. The
plus sign, on the other hand, is a way to concatenate text strings (a
deprecated way that no should ever use), so it doesn't do the coercion that
you need. To get it to work both ways, explicitly convert the text to
numeric

flydiff = Val(TextBox7.Text) + Val(TextBox10.Text)

The .Text and .Value properties are the same for textboxes.

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com

"Alvin Hansen" wrote in message
...
This one is working

flydiff = (TextBox7.Value - TextBox10.Value)
TextBox11.Value = flydiff

This one will not work
flydiff = (TextBox7.Value + TextBox10.Value)
TextBox11.Value = flydiff

Alvin





All times are GMT +1. The time now is 10:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com