Re: Type Mismatch problem
Quote:
Originally posted by stm
Hi,
I'm calling from ASP a function in MTS COM which was written in VB6 as:
Public Function GetStartTime(ByVal pstrClassCode As String) As ADODB.Recordset
and I call it in ASP like:
set rs2 = com.GetStartTime(rs.Fields("camtcd_class_code"))
The problem is that, if I don't use cstr() to enclose the parameter in asp, I will get the type mismatch error.
I read from msdn that, this error will occur when passing byref parameter, it must be defined as variant type. However, this seems does not match to my situation, can anyone tell me the problem?
Thx!!
Unlike VB6, In ASP/VBScript there is only "one" data type available and thats Variant. For example if you define a string in VB6 it would be :
Code:
Dim strMyString As String
Now in ASP/VBScript you will simply write :
Now that variable you defined is not a string rather a Variant, so when you pass that to your VB6 function which is expecting a String, you would get Data Type error. So thats why you would need to convert the variant to string using CStr.
So in summary, VBScript only have one Data Type and thats Variant.
Hope this helps.