Board index » delphi » VB activeX problem

VB activeX problem

Hello,

 I have this problem. If you could help me solve it it would be
great....

I have made a vb ActiveX control which has properties and functions
: both properties and functions return arrays via a Variant. In VB,
Delphi and VC++ clients I am able to access these arrays via the
properties. In VB and VC++ clients I can do the same via the functions
(the arrays are arguments, they are not actually the returned value of
the function) but I can not with Delphi : It gives me this kind of error

: "Invalid property value" :

function GetArrays(var tab as Variant)
CreateControl;
if FIntf = nil then DoCreate;
result := Fintf.GetArrays(tab);     <------ The error is here

I really do not know what s going on because I can make it work with
VC++

Thank you,

Daniel

--
(E-mail : Daniel.Az...@supaero.fr ou daz...@club-internet.fr)

 

Re:VB activeX problem


Quote
Daniel Aznar wrote in message <370DAB77.2A81A...@supaero.fr>...

>I have made a vb ActiveX control which has properties and functions
>: both properties and functions return arrays via a Variant. In VB,
>Delphi and VC++ clients I am able to access these arrays via the
>properties. In VB and VC++ clients I can do the same via the functions
>(the arrays are arguments, they are not actually the returned value of
>the function) but I can not with Delphi : It gives me this kind of error

>: "Invalid property value" :

>function GetArrays(var tab as Variant)
>CreateControl;
>if FIntf = nil then DoCreate;
>result := Fintf.GetArrays(tab);     <------ The error is here

>I really do not know what s going on because I can make it work with
>VC++

I'm assuming you typed your function definition wrong -
is it something like
  function TIntf.GetArrays(Tab : Variant) : Variant ?

So, this function takes a variant array, (maybe) creates
another instance of itself as a private field, then calls
the *same* method of *that* object to obtain a result?
Why? Is this right? What is FIntf?

Anyway, are you trying to create a new variant array? In
Delphi this must be done with a call to VarArrayCreate.

If this isn't the problem, then you probably need to post
more code (perhaps also the C++ code that works, and an
explanation of what you're trying to do with that function).

--
Jeremy Collins

Re:VB activeX problem


I am sorry, it was not very clear.

What I am trying to do is to develop an active X control with vb that has
methods that have arrays as parameters (integer and double arrays or
whatever).

So that is what I did with VB :

Public Function GetArrays(tab5 As Variant, tab6 As Variant) As Integer
    Dim i As Integer
    For i = 0 To 9
        tab5(i) = val5(i)
        tab6(i) = val6(i)
    Next i
    GetArrays = 0
End Function

Public Function SetArrays(tab5 As Variant, tab6 As Variant) As Integer
    Dim i As Integer
    For i = 0 To 9
        val5(i) = tab5(i)
        val6(i) = tab6(i)
    Next i
    SetArrays = 0
End Function

I know that I can use properties but I did it and it only works for one
array. I need to be able to have several arrays as arguments.

The Delphi code is the following :

   oaa : OleVariant;
   obb : OleVariant;
   occ : smallint;

// here some code that initializes the oaa and obb variants to respectively
smallint array and double arrays

    occ := tttt.SetArrays(oaa,obb);

this line is supposed to give the values of the arrays val5 and val6 to oaa
and obb.

and the error goes in the TLB.pas file :

function Tt.SetArrays(var tab5, tab6: OleVariant): Smallint;
var
   i : string;
begin
  CreateControl;
  Result := FIntf.SetArrays(tab5, tab6); <----here "Incorrect property value"

end;

In C++ I succeed in doing this because I use the COleSafeArray and its
methods.

Thank you for trying to help me

d

Re:VB activeX problem


Im Artikel <370DEED7.FB27D...@supaero.fr>, Daniel <daniel.az...@supaero.fr>
schreibt:

Quote
>    Dim i As Integer
>    For i = 0 To 9
>        tab5(i) = val5(i)

This code will work only, if the Variants do already contain arrays of the
correct types. Otherwise you have to ReDim tab5(9) first. So you should either
ReDim the arguments in the OCX, or prior to submitting the arguments to the OCX
method.

DoDi

Other Threads