Access VBA Programming for Beginners - Class 3 - by Patrick Lasu p_lasu@lycos.com
Class 3 - Overview Static Variables Message box Input Box
Static Variables A Static variable retains its value between calls to the procedure as long as the form is open. Syntax: Static varname [As Type] Very useful for maintaining counters within a local procedure. Example: Static intCount As Integer
Message Box A Message box is a handy tool to communicate with the user Gives information to the user Accepts user input There are many pre-set constants that makes the Message box very versatile Many times there is no need to create a custom Message box
Message Box Syntax: MsgBox(prompt[, buttons] [, title] [, helpfile, context]) Prompt = The message text Buttons = Optional – [OK] is default Title = Optional – The text in the blue bar Starting and closing parentheses ( ) are required only if you are receiving user input Return value is an integer between 1 and 7
Input Box Are useful if you want to receive input from a user Not as flexible as Message boxes Has a very “plain” look Accepts user input with either [OK] or [Cancel] buttons Not possible to distinguish between an “empty” user input or selecting [Cancel] It is possible to “control” it with code – Future Class!!!
Input Box Syntax: InputBox(prompt[, title] [, default] [, xpos] [, ypos] [, helpfile, context]) Prompt = Message to the user Title = Optional - The text in the blue bar Default = Optional - Default value provided to the user NOTE: Returns a String value of user input
Review of Class 3 Static variables are good for keeping count in a local procedure Message boxes are very versatile Use them often Input boxes are useful for user input Not the greatest, but it works
Next Class… Variable Conversion IF Statements IIF Statements Select Case Statements