Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Validations should be in the userform - I'll give you that. The
external approach I used was more like a demonstration of code possibilities rather than thougth-through methodology. At the end of the day it's a matter of preference - the way i see it - i don't like code with too many global variables - they get my head spin. In addition to that in the setup one still ends up with the global variable being tightly bound to the userform - so why not to have it encapuslated in it to begin with. I used to write codes with multiple global variables but along the way i realized that it wasn't for me. I recon the "Otherwise, wouldn't InputBox suffice?" wasn't really a question. On Dec 30, 7:13*pm, GS wrote: AB submitted this idea : 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. You cite a good point. This is precisely why I used a function to load the userform. That function clears any previous values in the vars before it opens the userform, ensuring that any values in the vars will be new to the current input. Note that I suggest the input values should be validated by the userform. This is so the userform purpose can be encapsulated and thus reusable. The procedure that processes the data doesn't need (nor shouldn't IMO) to know anything about how the data was collected in order to do its task, which only happens if the function was successful. This, in turn, depends on what happens in the userform as far as validation of input goes OR if the user cancels. Again, this should be handled in the userform. <FWIW Seems that popular opinion regarding userforms that collect data/input is that the userform should handle all validations and where the valid data goes. Our procedures that use/process the data should not be 'tied' to the userform in any way. Otherwise, wouldn't InputBox suffice? -- Garry Free usenet access athttp://www.eternal-september.org ClassicVB Users Regroup! comp.lang.basic.visual.misc- Hide quoted text - - Show quoted text - |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Text "comparison" operator for "contains" used in an "IF" Function | Excel Worksheet Functions | |||
Extract text plus "n" characters or date on partial match | Excel Programming | |||
Can you Click the "Enter" key to go to the next line in a Textbox without Exiting the Textbox ? | Excel Programming | |||
Insert "-" in text "1234567890" to have a output like this"123-456-7890" | Excel Discussion (Misc queries) | |||
How do I split "A1B2" into "A1" and "B2" using text to column fun. | Excel Programming |