Click to See Complete Forum and Search --> : UserControl


anita_vs
June 14th, 2001, 11:21 PM
Hi!

I need help for user control.

On "user control" I have ListBox.
I want to access that list box in form which is included in same usercontol. I wrote some code but it is giving error. error'424':object requried.

Usercontrol(test.ctl) code

Private Sub UserControl_Initialize()
Load Form1
List1.AddItem "A", "0"
List1.AddItem "K", "1"
List1.AddItem "G", "2"
List1.AddItem "R", "3"
End Sub

Private Sub cmdbutton_Click()
Form1.Show vbmodel,me
End Sub

Form1
Private Sub Form_Load()
txttest.value=test.list1.text
(Nameof usercontrol.controlname.property)
End Sub

I am not able to refernce the component from usercontrol.

Thanks,
Anita

cksiow
June 14th, 2001, 11:33 PM
if the list box is in the form, should you write

form1.list1.additem

instead ?

cksiow
http://vblib.virtualave.net - share our codes

Tower
June 15th, 2001, 12:44 AM
I think you need writing function in UserControl.
In user control write:
Public Function RetProp() As String
RetProp = List1.Text
End Function

In form use:
txttest.value = test.RetProp()

P.S. In listbox properties Text return zero lenght value string