Do you need to use Val? You may be able to use CDbl instead, but you'll need to make sure the string is numeric first.
As a function: (Returns 0 if not numeric)Code:If IsNumeric(Text1.Text) Then dblValue = CDbl(Text1.Text) Else dblValue = 0 End If
Code:Public Function MyVal(Number As String) As Double If IsNumeric(Number) Then MyVal = CDbl(Number) End Function




Reply With Quote