|
-
Jan 15th, 2002, 11:58 PM
#1
Thread Starter
Junior Member
Arrays
I've got a populated listbox on a form, whose items I'd like to access from a second form. I've set up my first form so that it imports the second form, but I still can't seem to access it. Here's the code:
Imports myApp.frmPrefs
'Dim temp to use in the for each loop
Dim temp as String
'Add items from preferences to the items of the cboPayment
For Each temp In lstPaymentOptions
cboPayment.Items.Add(temp)
Next
So lstPaymentOptions is a listbox on Form2, and I want to access its members from Form1, and ultimately make it's items the choices in a combo drop down box.
Any help you folks could offer would be greatly appreciated!!
Thanks!!
Reid
-
Jan 16th, 2002, 04:39 AM
#2
Hyperactive Member
Using the "Imports" statement as you have done just makes available the form class, not the specific form object.
To achieve what you wish to do you will need to extend the scope of your listbox from form2.
One way to do this is to set up a Public property that accesses it.
For example in Form2.
VB Code:
Public Property ShareListBox() As ListBox
Get
ShareListBox = ListBox1
End Get
Set(ByVal Value As ListBox)
ListBox1 = Value
End Set
End Property
Now, assuming form1 has a reference to the form2 object then it can access the listbox via the sharelistbox property.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|