944,161 Members | Top Members by Rank

Ad:
Jun 4th, 2007
0

vb control array

Expand Post »
Hi,

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

cguan
Similar Threads
Reputation Points: 19
Solved Threads: 115
Nearly a Posting Virtuoso
cguan_77 is offline Offline
1,317 posts
since Apr 2007
Jun 4th, 2007
0

Re: vb control array

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.
Reputation Points: 30
Solved Threads: 49
Posting Pro
choudhuryshouvi is offline Offline
553 posts
since May 2007
Jun 5th, 2007
0

Re: vb control array

'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
Reputation Points: 19
Solved Threads: 115
Nearly a Posting Virtuoso
cguan_77 is offline Offline
1,317 posts
since Apr 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Flex Grid error "Invalid procedure call or argument"
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Using VB to compile columns in MS Access





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC