This is a pretty frustrating problem with VB6, and I'm hoping someone knows the solution...
I have a user-defined type declared in a module file:
And in the same module, a function:Code:Public Type T_PRODUCT_STEP StepId As Long End Type
Now, no matter what I do I can't get the function to return the array or read it on the other side. The above code returns an error on "ProductStepList = StepListRet" (can't assign to array). If I try:Code:Public Function ProductStep(MyVar As String) as T_PRODUCT_STEP() Dim StepListRet() As T_PRODUCT_STEP ReDim StepListRet(3) StepListRet(0).StepId = 1 StepListRet(1).StepId = 2 StepListRet(2).StepId = 3 StepListRet(3).StepId = 4 ProductStepList = StepListRet End Function
I get an error on the first StepId assignment (argument not optional, looks like it's trying to call the function instead of assigning to an array).Code:Dim StepListRet() As T_PRODUCT_STEP ReDim ProductStepList(3) ProductStepList(0).StepId = 1 ProductStepList(1).StepId = 2 ProductStepList(2).StepId = 3 ProductStepList(3).StepId = 4
If I comment everything except the ReDim ProductStepList(3) the program executes, and I can read the array of empty type elements, ie.:
I just can't populate the newly created array with values. Anyone have any ideas?Code:Dim test() as T_PRODUCT_STEP test = ProductStepList("dfd") Msgbox test(2).StepId
Easiest solution would be to use Variants everywhere, but shouldn't have to...
Thanks,
Brian




Reply With Quote