+ Reply to Thread
Results 1 to 2 of 2

please help

  1. #1
    King
    Guest

    please help

    Hi,

    i have a requirement. i have five buttons on a sheet, and when user
    clicks on a button, a form with a listbox will be displayed. the
    listbox will be poppulated with the data based on which button user has
    selected. i mean, each button click event will generate a unique array,
    and all the member of array will be added to the listbox in the form. i
    can create five different form to do that. but i want to know that, can
    i use the same form to perform this operation for all five buttons?

    Thanks,

    King.


  2. #2
    AMDRIT
    Guest

    Re: please help

    Certainly you can.

    create your userform, name it frmTest
    add to it a listbox, name is lstData

    create a private sub routine named, PopulateData

    private sub PopulateData
    dim iLoop as integer

    for iLoop = 1 to 100
    'If you choose option A
    lstData.additem "Option " & CurrentOption & " Item " & iLoop
    'If you choose option B
    lstData.additem "Option " & m_CurrentOption & " Item " & iLoop
    next iLoop

    end sub

    now then, option A

    add a module, name is basMain
    in the module create a public variable CurrentOption
    --> Option Explicit
    --> public CurrentOption as Integer

    Option B

    in the userform code module create a public routine sub, named Init
    and a private variable, m_CurrentOption
    -->Public Sub Init(buttonoption as integer)
    --> m_CurrentOption = buttonoption
    -->End Sub

    Finally on Button Click of each of your buttons

    OpenForm <ButtonOption>

    private sub OpenForm(ButtonOption as integer)
    dim f as frmTest
    set f = new frmTest

    if option a then CurrentOption = ButtonOption
    if option b then f.init ButtonOption
    f.show vbmodal
    end sub



    "King" <tjbhandari@gmail.com> wrote in message
    news:1131139885.538948.295360@z14g2000cwz.googlegroups.com...
    > Hi,
    >
    > i have a requirement. i have five buttons on a sheet, and when user
    > clicks on a button, a form with a listbox will be displayed. the
    > listbox will be poppulated with the data based on which button user has
    > selected. i mean, each button click event will generate a unique array,
    > and all the member of array will be added to the listbox in the form. i
    > can create five different form to do that. but i want to know that, can
    > i use the same form to perform this operation for all five buttons?
    >
    > Thanks,
    >
    > King.
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1