Type problem: passing variables to methods 
Author Message
 Type problem: passing variables to methods

I am using two different controls (iTwain and Kodak/Wang ImagScan) that
use arguments in a method call. ImagScan (and probably iTwain) is
written in C++, and they expect certain variable types as parameters.

Problem: There is no way to type a variable in VBScript. Everything is
variant, and specifying a variant subtype (via csng or formatnumber,
for example) doesn't work. Even if I explicitly list the argument
(rather than using a variable), VBscript must be implicitly converting
the variable to type variant before passing the variables to the
method.

Example
method specification:
controlname.SetTransferFile (String filename, Short filetype)
Code:
Twain1.SetTransferFile("d:\Erik\Scanned_images\twaintest.tif",0)
Error:
Type mismatch

Using variables as arguments doesn't work either.
Any ideas on a workaround would be greatly appreciated.

--
Erik Slotboom

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Mon, 25 Mar 2002 03:00:00 GMT  
 Type problem: passing variables to methods
Have you tried doing the type conversion in the function call parameter list
such as :

("d:\Erik\Scanned_images\twaintest.tif",CInt(0))


Quote:
> I am using two different controls (iTwain and Kodak/Wang ImagScan) that
> use arguments in a method call. ImagScan (and probably iTwain) is
> written in C++, and they expect certain variable types as parameters.

> Problem: There is no way to type a variable in VBscript. Everything is
> variant, and specifying a variant subtype (via csng or formatnumber,
> for example) doesn't work. Even if I explicitly list the argument
> (rather than using a variable), VBscript must be implicitly converting
> the variable to type variant before passing the variables to the
> method.

> Example
> method specification:
> controlname.SetTransferFile (String filename, Short filetype)
> Code:
> Twain1.SetTransferFile("d:\Erik\Scanned_images\twaintest.tif",0)
> Error:
> Type mismatch

> Using variables as arguments doesn't work either.
> Any ideas on a workaround would be greatly appreciated.

> --
> Erik Slotboom

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Mon, 25 Mar 2002 03:00:00 GMT  
 Type problem: passing variables to methods

VBScript (or more accurately the default OLE IDispatch implementation) will coerce variants to strongly typed ByVal arguments, but not to strongly typed ByRef arguments.  Not all components are "script friendly" and may expect strongly typed ByRef arguments when not strictly needed.

--
Michael Harris

  I am using two different controls (iTwain and Kodak/Wang ImagScan) that
  use arguments in a method call. ImagScan (and probably iTwain) is
  written in C++, and they expect certain variable types as parameters.

  Problem: There is no way to type a variable in VBscript. Everything is
  variant, and specifying a variant subtype (via csng or formatnumber,
  for example) doesn't work. Even if I explicitly list the argument
  (rather than using a variable), VBscript must be implicitly converting
  the variable to type variant before passing the variables to the
  method.

  Example
  method specification:
  controlname.SetTransferFile (String filename, Short filetype)
  Code:
  Twain1.SetTransferFile("d:\Erik\Scanned_images\twaintest.tif",0)
  Error:
  Type mismatch

  Using variables as arguments doesn't work either.
  Any ideas on a workaround would be greatly appreciated.

  --
  Erik Slotboom

  Sent via Deja.com http://www.deja.com/
  Before you buy.



Tue, 26 Mar 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Passing a variable using hidden method.

2. Passing variables to a com object method written in VB

3. How to pass Date type variable to a custom ActiveX component

4. Passing a variable type parameter to an .asp file

5. passing TYPE Variables

6. calling object methods on a variable with interface type

7. Passing dynamic array of custom type to form method from another form

8. Passing User Defined Type as a parameter in method gives a VB5 error

9. Passing User Defined Type as a parameter in method gives a VB5 error

10. passing "type" variables HELP plz

11. Help with passing user defined types as variables in functions - VB4 32bit

12. Problem passing XMLDOC to COM Method

 

 
Powered by phpBB® Forum Software