Working with Forms in Visual Basic
The main characteristic of a Form is the title bar
CONTROL MENU Restore : Restores a maximized Form to the size it was before it was maximized; available only if the Form has been maximized. Move : Lets the user moves the Form around with the mouse Size : Lets the user resizes the control with the mouse Minimize: Minimizes the Form Maximize : Maximizes the Form Close : Closes the Form
Loading and Unloading Forms Load and Unload statements in VB Load FormName Unload FormName
Showing and Hiding Forms Show method is used to Show a Form FormName.Show The Hide method is used to hide a Form Me.Hide Me is the form name, Keyword
OBJECT PROPERTY SETTING Form Caption Name Form1 frm1 Form2 frm2 Form3 frm3 Label Click on a button to display a Form Label1
Variables
Variables Variables are the memory locations which are used to store values temporarily. Rules A variable name must begin with an alphabet letter and should not exceed 255 characters. It must be unique within the same scope. It should not contain any special character like %, &, !, #, @ or $.
Syntax Dim variable [As Type] Dim I as integer Dim intInterestRate As Integer = 10
Scope of variables A variable is scoped to procedure-level (local) -Global module-level – Local They can be declared with Dim and Static keywords.
Local Variables A local variable is one that is declared inside a procedure. Dim sum As Integer The local variables exist as long as the procedure in which they are declared, is executing.
Static Variables A static variable is declared as given below. Static intPermanent As Integer Variables have a lifetime in addition to scope.
DATATYPES Numeric Data Types Non-numeric Data Types Suffixes for Literals