I think the mistake you did is that, you had named your variable as 'val'. This
is wrong. Because val is a keyword of Visual Basic and if you've some string or
text and want to convert the same into a number (integer) then you can use this
Val function.
For example see the below code.
Dim X as String
Dim Y as Integer
Dim Z as Integer
X=2
Y=3
' Now I want to add X & Y and get the result in Z
Z = X+Y
Msgbox Z
'''' If I do like this then it will give me an error message stating that 'Type
Mismatch'.
---- The reason is I've defined the variable X as string and adding a String and
an Integer. So comes the error. If both were strings then the result will be 2+3
as such. The '+' (plus) sign will be used automatically by Visual Basic for
concatinating the two strings.
But actually here we've one string and one integer, so it will show an error.
Then you have to do a little modification here, like below in the sumation
point.
Z= Val(X)+Y
' now you will get 5 as the result in the msgbox.
So try changing the variable name and let us know the status of your result or
error.