vb control array

Thread Solved

Join Date: Apr 2007
Posts: 1,108
Reputation: cguan_77 has a little shameless behaviour in the past 
Solved Threads: 91
cguan_77's Avatar
cguan_77 cguan_77 is offline Offline
Veteran Poster

vb control array

 
0
  #1
Jun 4th, 2007
Hi,

Can anyone help me, how to determine selected control from an array of listbox? Anyhelp is greatly appreciated. Thanks.

cguan
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 537
Reputation: choudhuryshouvi is an unknown quantity at this point 
Solved Threads: 49
choudhuryshouvi's Avatar
choudhuryshouvi choudhuryshouvi is offline Offline
Posting Pro

Re: vb control array

 
0
  #2
Jun 4th, 2007
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. 'used stuffs :- list1 and its two arrays(0,1)
  2.  
  3. 'displaying name along with its index of the selected control
  4. Private Sub List1_Click(Index As Integer)
  5. MsgBox List1(Index).Name & "(" & Index & ")"
  6. End Sub
  7.  
  8. 'dynamically adding items to all listboxes present on the current form
  9. Private Sub Form_Load()
  10. Dim ctlControl As Object
  11. On Error Resume Next
  12. For Each ctlControl In Me.Controls
  13. If TypeOf ctlControl Is ListBox Then
  14. ctlControl.AddItem "computer"
  15. DoEvents
  16. End If
  17. Next ctlControl
  18. End Sub
Last edited by Comatose; Jun 8th, 2007 at 2:46 pm.
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 1,108
Reputation: cguan_77 has a little shameless behaviour in the past 
Solved Threads: 91
cguan_77's Avatar
cguan_77 cguan_77 is offline Offline
Veteran Poster

Re: vb control array

 
0
  #3
Jun 5th, 2007
Originally Posted by choudhuryshouvi View Post
'used stuffs :- list1 and its two arrays(0,1)

'displaying name along with its index of the selected control
Private Sub List1_Click(Index As Integer)
MsgBox List1(Index).Name & "(" & Index & ")"
End Sub

'dynamically adding items to all listboxes present on the current form
Private Sub Form_Load()
Dim ctlControl As Object
On Error Resume Next
For Each ctlControl In Me.Controls
If TypeOf ctlControl Is ListBox Then
ctlControl.AddItem "computer"
DoEvents
End If
Next ctlControl
End Sub
thanks choudhuryshouvi it really works..thank you so much
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC