Variable in Textbox Event

helivw

New Member
Joined
Oct 6, 2018
Messages
26
I make a selection in a Userform.Listbox with data coming form the Textbox in a Userform
Can I pass a variable to the Textbox Sub ..._Change event
ie. Sub TextBx_Change(ByRef ....)
I don't want to use a Public variable
Thanks
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
I make a selection in a Userform.Listbox with data coming form the Textbox in a Userform
Can I pass a variable to the Textbox Sub ..._Change event
ie. Sub TextBx_Change(ByRef ....)
I don't want to use a Public variable
Thanks

Can you use the TextBox Tag Property to store the data ?
 
Upvote 0
What is the data type of the array?
A delimited string and an array are pretty much the same information.
 
Upvote 0
That would be a long delimited string. A module wide variable would be the easiest way to pass it. What is your concern about using a public variable?
 
Upvote 0
That would be a long delimited string. A module wide variable would be the easiest way to pass it. What is your concern about using a public variable?

Because I read everywhere, you have to avoid using public variables and I use a lot of userforms (very handy) and each time I'm fighting of finding a easy way to transfer variables between my subroutine and parts (listbox, textbox, ...) of the userform and vv
 
Upvote 0
Can't you use module level variables instead of Public global variables - Each variable declared at the top of each userform module so you can use them throughout the entire userform lifetime and scope.
 
Last edited:
Upvote 0
Can't you use module level variables instead of Public global variables - Each variable declared at the top of each userform module so you can use them throughout the entire userform lifetime and scope.

Thanks a lot Jaafar.
I really never thought that way, shame on me.

And what would be te best way to transfer my array to a userform Sub i.e. the userform initialize or whathever before my command
Userform.Show
 
Upvote 0
The userform Initialize event fires before showing the userform so that's a good place to populate the array.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top