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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Text to Value Convertion 1

Status
Not open for further replies.

ninash

Technical User
Jul 6, 2001
163
GB
Hi Guys,

This is I hope a simple problem
I have 2 text boxes in a user from and I need to add the 2 values together to evaluate the result. Unfortunately both of the values are being seen as text and I need to see them as numbers ..... Anyone out there to help me
 
Sheets("sheet1").Shapes("Text Box 1").Select
x = Val(Selection.Characters.Text)

Sheets("sheet1").Shapes("Text Box 3").Select
x = x + Val(Selection.Characters.Text)

MsgBox (Str$(x))
 
OR.........
This sits nicely in the code for the sheet containing the text boxes

Option Explicit

Sub test()
Dim x As Single
x = CSng(Txt1) + CSng(Txt2)
MsgBox x

End Sub

Obviously if the values are to be integers change x and substitutes CInt for CSng
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top