Reputation: 4434
So let's say I have a listbox called lstFruits, that contains some words in there. Now let's say I have a string strString which contains "lstFruits" (the name of the listbox).
So strString = "lstFruits".
How do I go from the string to activating and giving focus to the lstFruit listbox? I know there's lstFruits.Select or lstFruits.Focus....but I want to be able to activate the listbox from the string strString....Eventually I'd like strString to contain the name of 1 listbox out of many possible ones, and give focus to the listbox spelled out by strString.
Upvotes: 2
Views: 1584
Reputation: 30398
The VB6 version is
Me.Controls("lstFruits").SetFocus
Documentation: SetFocus, Controls collection
Upvotes: 1
Reputation: 13931
Im not sure if this will work in VB6, i tested it on VB.NET
Me.Controls("lstFruits").Focus()
Where "Me" represents your form or other "container" control which contains listbox.
Upvotes: 2