excel vba cast string to number code example
Example 1: excel vba convert string to a number if string is a number
MsgBox Val(str)
'If string does not start with a numeric text value, Val() returns a zero.
Example 2: excel vba make integer
Public Function MakeInteger%(LoByte As Byte, HiByte As Byte)
If HiByte And &H80 Then
MakeInteger = ((HiByte * &H100&) Or LoByte) Or &HFFFF0000
Else
MakeInteger = (HiByte * &H100) Or LoByte
End If
End Function