change text box form

Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Change Text Box form String to Integer

Change Text Box form String to Integer

resolvedResolved · Low Priority · Version 2003

Daren has attended:
Excel VBA Intro Intermediate course

Change Text Box form String to Integer

I have 2 values form text boxes, These are numeric values When I try to add them to gether (ie 2 + 3) I get the value 23 instead of the value 4

The same values are also put in a cell on a Excel sheet which states that they are stored as text.

Should the string forn the text box be changed to an integer, if so how do you change it

below is the programming

TextBoxIn_Hours + TextBoxOut_Hours1

RE: Change Text Box form String to Integer

Hi Daren, thanks for the query and apologies for the delaying in replying. Your code is concatenating the text rather than adding together the values in the textboxes. Try this code out:

(Val(TextBoxIn_Hours) + Val(TextBoxOut_Hours1))

Hope this helps,

Anthony

RE: Change Text Box form String to Integer

Hi Anthony

This works fine

Thank you very much

Regards

Daren

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Excel tip:

Ctrl+d's double life

Suppose I have a formula in B1 that I wish to copy into B2:B10. I can select B1:B10 then press Ctrl+d to copy the formula down the selected range. Users generally ignore this shortcut in favour of double-clicking on the fill handle to copy down, but Ctrl+d is useful sometimes particularly when there is no data in surrounding columns to guide to how far the double-click method should copy formulae.

Ctrl+d has another use though. When I use the drawing toolbar to draw objects such as Text Boxes, Rectangles and Ovals onto a worksheet, Ctrl+d makes an instant duplicate of selected shapes. For example, I need five Text Boxes the same size. I draw one Text box and adjust it to the size I want, select it, then press Ctrl+d four times to get four identical copies.

View all Excel hints and tips


Server loaded in 0.08 secs.