"Parameter Type Mismatch" Passing TYPE Array to QB 4.50 SUB (70268)



The information in this article applies to:

  • Microsoft QuickBASIC 4.5

This article was previously published under Q70268

SYMPTOMS

The code example below shows a very specific and obscure problem in QB.EXE 4.50 with passing an array of user-defined TYPEs to a SUBrogram. The problem occurs only in QB.EXE in the program below when you define six user-defined TYPEs, dimension an array using the sixth TYPE, and pass that one array to a subprogram. The problem incorrectly gives you a "Parameter Type Mismatch" error message in the QB.EXE environment. The problem does not occur in the compiled .EXE version of the program. The problem can easily be worked around as shown below.

STATUS

Microsoft has confirmed this to be a bug in QB.EXE only in Microsoft QuickBasic version 4.50. This problem is corrected by QBX.EXE in Microsoft Basic Professional Development System (PDS) version 7.00 (fixlist7.00) for MS-DOS. This problem does not exist in QuickBasic versions earlier than QuickBasic 4.50.

MORE INFORMATION

To reproduce the error in QB.EXE, you will have to set up the exact number of TYPEs and variables as listed below. Any deviation to the program below could cause the program to run correctly.

The program defines six TYPEs and passes one of those TYPEs to the subprogram. If you remove the remarks and add a new TYPE, the program runs correctly. If you remark out any single element of any of the first five TYPEs, the program runs correctly.

The workarounds for this program are:

  1. Take out an element of one of the first five TYPEs -or-

  2. Add a dummy TYPE that does not have to refer to anything. By adding a dummy TYPE, even if you do not use it in a subprogram or dimension a variable as being of that TYPE, the program will run properly in QB.EXE.

Code Example

' The following program will give you a "Parameter Type
' Mismatch" in QB.EXE from QuickBasic 4.50. No error in .EXE.

DECLARE SUB sub1 (tt() AS ANY)
'TYPE oof             <-- get rid of the remarks in
'  myvar AS INTEGER   <-- these three statements and
'END TYPE             <-- the program works.

TYPE one
  a AS DOUBLE
  b AS DOUBLE
  c AS DOUBLE
END TYPE

TYPE two
  d AS DOUBLE
  e AS DOUBLE
  f AS DOUBLE
END TYPE

TYPE three
  g AS INTEGER
  h AS INTEGER
  i AS INTEGER
  j AS INTEGER
  k AS INTEGER
  l AS STRING * 3
  m AS two
END TYPE

TYPE four
  n AS DOUBLE
  o AS DOUBLE
  p AS DOUBLE
  q AS DOUBLE
  r AS DOUBLE
  s AS DOUBLE
  t AS DOUBLE
  u AS DOUBLE
END TYPE

TYPE five
  v AS INTEGER
  w AS INTEGER
END TYPE

TYPE six
  x AS STRING * 40
  y AS INTEGER
  z AS INTEGER
  a1 AS DOUBLE
  b1 AS five
  c1 AS five
  d1 AS five
  e1 AS five
  f1 AS five
  g1 AS INTEGER
  h1 AS INTEGER
END TYPE

' DIM an array as the sixth TYPE:
DIM tt(1 TO 2) AS six

' Pass the array of TYPEs to the subprogram
' and error occurs here with "tt" highlighted:
CALL sub1(tt())
END

SUB sub1 (tt() AS six)
END SUB
				

Modification Type:MinorLast Reviewed:1/9/2003
Keywords:KB70268