Values ListBox of Form1 into Form2(VB 6.0)

Posted on 2004-11-04
Last Modified: 2012-05-05
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.
- Colum of MSHFLEXGRID is Form1.list2(Select)
- Row of MSHFLEXGRID is Form1.list1(Select)

help me
Thank you!

Question by:thang74us
    LVL 19

    Expert Comment

    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???

    Author Comment

    I want creat 1 Public array a(100) as interger in Form2.
    And write code in form1: form2.a()=

    but msgbox erorr

    Not allowed as public member of object modues

    help me
    Thank you.
    LVL 19

    Accepted Solution

    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


    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
        For i = 0 To UBound(Arr) - 1
        MsgBox Arr(i)
    End Sub

    Call it as this from Form1



    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Purpose To explain how to place a textual stamp on a PDF document.  This is commonly referred to as an annotation, or possibly a watermark, but a watermark is generally different in that it is somewhat translucent.  Watermark’s may be text or graph…
    Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now