Passing an array to a component

Results 1 to 3 of 3

Thread: Passing an array to a component

  1. #1
    Ian Smith Guest

    Default Passing an array to a component

    Seems I may have posted this in the wrong place first time.<BR><BR>Help! I have a VB COM component used to "validate" an array of telephone numbers. The array <BR>can have holes in it because it&#039s populated from drop-down list-box of "phone number type"s<BR>like those used in Microsoft Outlook. <BR><BR>Any attempt to invoke the component from an ASP page just causes a "Type Mismatch" error, <BR>but from a VB test module it&#039s fine. Note that variants have been used throughout and I&#039ve <BR>read every Knowledgebase article about ASP only using variants until I&#039m red in the face -<BR>nothing has helped. The ASP page still refuses to pass the data across to the COM component. <BR>I have tried every combination of array variants, variants as arrays etc I can think of, <BR>but am getting absolutely nowhere.<BR><BR>The COM component is coded to expect the following....<BR><BR> Public Function Validate(TelArray() As Variant, _<BR> ErrMsg As Variant) _<BR> As Boolean <BR><BR>The "test case" written to use variants and which works fine from VB is as follows...<BR><BR> Dim varInput(3, 4) As Variant<BR> Dim strErrMsg<BR> Dim blnRowCount<BR> varInput(0, 0) = "1"<BR> varInput(1, 0) = "+44"<BR> varInput(2, 0) = "01628"<BR> varInput(3, 0) = "413688"<BR> varInput(0, 1) = "2"<BR> varInput(1, 1) = "+44"<BR> varInput(2, 1) = "0410"<BR> varInput(3, 1) = "999999"<BR> varInput(0, 2) = "2"<BR> varInput(1, 2) = "+44"<BR> varInput(2, 2) = "01628"<BR> varInput(3, 2) = ""<BR> varInput(0, 3) = "4"<BR> varInput(1, 3) = "+44"<BR> varInput(2, 3) = "01628"<BR> varInput(3, 3) = ""<BR> varInput(0, 4) = "5"<BR> varInput(1, 4) = "+44"<BR> varInput(2, 4) = "01628"<BR> varInput(3, 4) = ""<BR> MsgBox "TypeName =" & TypeName(varInput)<BR> Set objBus = CreateObject("BonvenoBus.TelRequest")<BR> blnRowCount = objBus.Validate(varInput, strErrMsg)<BR><BR>The same code (without the MsgBox because VBScript doesn&#039t support the "TypeName" function)<BR>gives "Type Mismatch" on the last line when run in an ASP page. I&#039ve tried co-ercing the<BR>damned array into a single variant, as hinted at in "Advanced VB". Nothing. I&#039ve done<BR>every thing there is to be done with ParamArray. Still no joy. Surely there has to be <BR>a way to get this damned thing so it works with VB AND ASP.<BR><BR>Typename reveals "Variant()" when run in VB. Using the ASP debugger the "varInput" structure<BR>shows as "Array of variant" in the Watch window.<BR><BR>Help!<BR><BR>Ian

  2. #2
    Join Date
    Dec 1969
    Posts
    25

    Default RE: Passing an array to a component

    pass the info like this it may work<BR>Dim varinput(3,4) As an Array<BR>or you could secure the varible so it does not change in value by doing the Set command in front of each instance of the array

  3. #3
    Ian Smith Guest

    Default RE: Passing an array to a component

    You can&#039t use the "As..." command in ASP - everything gets declared a variant. <BR><BR>Thankfully someone from the VB User Group came up with the answer..<BR><BR>In the VB component remove the brackets from the array declaration to give <BR>Public Function Validate(TelArray as variant,....<BR><BR>Then define vArray in ASP (it will be defined as a variant) and assign it to the array so that it becomes a variant holding an array:<BR><BR>vArray = varInput<BR><BR>and now call the COM component with<BR><BR>blnRowCount = objBus.Validate(vArray,strErrMsg)<BR><BR>It works!<BR><BR>Ian

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •