View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
AB[_2_] AB[_2_] is offline
external usenet poster
 
Posts: 236
Default Extract text from a "textbox"

The reason i do it this way (and - as per the code - i terminate the
form and don't keep it in memory longer than necessary) is otherwise
there is way big of a chance (for me anyway) that the global variables
would have retained the value from previous user entry and not the
current one - as that's the whole point - you give it a value, it
keeps it as long as in compile state.
But when a code grabs that public varialbe - how would it know whether
that is an entry that the user typed into the form just now or 60mins
ago? To manage that aspect strict controls need to be in place and i
find the
form.hide
read control value
unload form
method more convenient and safer especially it's not such a big of a
drag onto the pc's memory anyway.
Just my 0.02 of worth.



On Dec 30, 4:31*pm, GS wrote:
AB expressed precisely :





In the userform you need a button (like btnOK) that has btnOK_click
event something like this:


btnOK_click
* *'do some validation here and exit sub in case fails
* *me.hide'Hides (as oppose to terminate/destroy) the form keeping all
controls alive/available
end sub


Your DoStuff then would be something like this:


Sub DoStuff ()


Dim first_name as String
Dim last_name as String


UserForm.Show * ' Show form with text boxes
'user types the f/l names into the textboxes
'user clicks on the btnOK (that hides the form but keeps it alive)
first_name=UserForm.txtbx_FName.Text'Read First Name
last_name=UserForm.txtbx_FName.Text'Read Last Name


Unload UserForm'Terminate the form


End Sub


I agree that your suggestion will work, but I don't see the point to
keeping the userform loaded in memory. I whole heartedly agree with
Rick on this approach even though there's any number of other ways to
get this done!

--
Garry

Free usenet access athttp://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc- Hide quoted text -

- Show quoted text -