Variable in Textbox Event

helivw

New Member
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
 

Jaafar Tribak

Well-known Member
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 ?
 

mikerickson

MrExcel MVP
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?
 

helivw

New Member
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
 

Jaafar Tribak

Well-known Member
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:

helivw

New Member
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
 

Some videos you may like

This Week's Hot Topics

Top