To avoid the Type Mismatch error, use the built-in CSng function to convert the string stored in the value1 variable to a Single type number
Sub AddTwoNums2()
Dim myPrompt As String
Dim value1 As String
Dim mySum As Single
Const myTitle = "Enter data"
myPrompt = "Enter a number:"
value1 = InputBox(myPrompt, myTitle, 0)
mySum = CSng(value1) + 2
MsgBox mySum & "(" & value1 & "+2)"
End Sub
Related examples in the same category