Re: Type Mismatch When Set VB Com Property to Request Form Numeric Var

From: Chris Barber (chris_at_blue-canoe.co.uk.NOSPAM)
Date: 10/13/04


Date: Wed, 13 Oct 2004 02:59:29 +0100

You could change your COM component to accept a variant and then it would be implicitly coerced in
the value assignment for the property.

Try this in VB and see what results:

Dim pstrString as String
pstrString = 6

You get a mismatch error? No .. that's because the assignment operator is doing the coercing to a
string datatype for you. When passing a value to a COM object, the datatype has to match explicitly
(or be a variant) since the error is raised at the COM interface as opposed to the in the actual VB
code (I think).

BTW: It's a good idea to use variant as parameters when the COM component is intended to be called
from ASP (or any script engine) to alleviate this type of issue.

NB: The ASP code *should* be explicitly casting textbox values to string etc. in the validation
process for user entered data - not your code I presume?

Chris.

"gf" <gf@discussions.microsoft.com> wrote in message
news:707F0447-38AE-4CB4-B476-9A0FA1E146B3@microsoft.com...
Hi,
We are moving existing, production ASP 2 and VB6 code from NT4/IIS4 to
Windows 2003/IIS6.
We get a Type Mismatch error when we try to assign a numeric sub-type
Variant value to a VB6 component property.
For example (where myCom is the VB6 component setup in a COM+ Package),
myCom.Zip = Request.Form("ZipCode")
results in a Type Mismatch when "ZipCode" is entered as a numeric value on
the web page form.
If we change the ASP code to this
myCom.Zip = CStr( Request.Form("ZipCode") )
the ASP code works fine.
However, we have "Lots" of lines of code like the first example and would
prefer not to have to change (and restest) all of our code.
Is there a setting we might be missing in the IIS server?
Any suggestions are appreciated.
thanks...gf...

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.776 / Virus Database: 523 - Release Date: 12/10/2004


Relevant Pages

  • Update data via DLL
    ... I have an ASP code like this: ... <% Set objWO = server.CreateObject ... Public Function WoStUpdate(Wonum As Variant, Status As Variant, ID As Variant) ... Does anybody know why I got this error page when the database is actually get updated? ...
    (microsoft.public.inetserver.asp.db)
  • Re: C# Language Proposal for out Parameters
    ... > assignment in the method body. ... As you said it was a proposed variant. ... >> a) if GetNewValue returns true, the copyout operation will assign the ... >> if var is passed one level further in inout mode). ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How to return reference of value from function?
    ... Writing to the function return ... >would not modify the source of that assignment. ... A Variant result is a 'phantom' parameter on the stack ... Not an EAX ...
    (microsoft.public.vb.com)
  • Re: How to return reference of value from function?
    ... Writing to the function return ... >would not modify the source of that assignment. ... A Variant result is a 'phantom' parameter on the stack ... Not an EAX ...
    (microsoft.public.vb.enterprise)
  • Re: How to return reference of value from function?
    ... Writing to the function return ... >would not modify the source of that assignment. ... A Variant result is a 'phantom' parameter on the stack ... Not an EAX ...
    (microsoft.public.vb.general.discussion)

Loading