I believe I’ve used this before in RS, but I’m getting an error now. Simple code:
Dim s As String = "123"
Dim i As Integer = CType(s, Integer)
I receive an error: Type mismatch error. Expected Int32, but got String
Does cType only work on numeric values?
Ctype is for converting between value representation (i.e. unsigned 32bit number to signed 32bit number to single to double)
To turn a string that represents a number i.e. “12345” you need to use Val() etc.
Ctype (for the most part) doesn’t actually change the underlining value stored in a variable, it just changes how it is interpreted. A string however is several bytes long, quickly exceeding the size of any CPU register and the characters do not in any way map to actual values (except for single digits) so they have to be computed into a value via val()
I believe that the CType method only performs conversions which can also be done implicitly.