Values ListBox of Form1 into Form2(VB 6.0)

I have 2 Form (name: Form1 and form2)

- Form1 have list1,list2(MultiSelect=2). I click choose many row of list1 and list2.

I want, When Click  CmdOk of Form1 then Form2 load 1 MSHFlexGrid.
MSHFLEXGRID of Form2:
- Colum of MSHFLEXGRID is Form1.list2(Select)
- Row of MSHFLEXGRID is Form1.list1(Select)

help me
Thank you!

thang74usAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

arif_eqbalCommented:
What do you mean - Row of MSHFLEXGRID is Form1.list1(Select)

Say user selects 5 items from List1 and 3 items from list2

How should it be placed in the FlexGrid???
0
thang74usAuthor Commented:
I want creat 1 Public array a(100) as interger in Form2.
And write code in form1: form2.a()= list1.select(i)

but msgbox erorr

Not allowed as public member of object modues

help me
Thank you.
0
arif_eqbalCommented:
Yes you'd get that error as Array declaration as Public is not allowed in VB6

So what you can do is have the array as private (simple Dim)

and have a public Function in Form2 called FillArray and pass the Listbox object to it

eg.

Public Sub FillArray(Lst As ListBox)
    Dim i As Integer
    ReDim Arr(0)
    For i = 0 To Lst.ListCount - 1
        If Lst.Selected(i) = True Then
            Arr(UBound(Arr)) = Lst.List(i)
            ReDim Preserve Arr(UBound(Arr) + 1)
        End If
    Next
    For i = 0 To UBound(Arr) - 1
    MsgBox Arr(i)
    Next
End Sub

Call it as this from Form1

Form2.FillArray(Me.List1)

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.