Summary
Highlights
The video begins by creating a new Visual Basic Windows Forms application. The form is set up with a button, which is renamed 'btnGo' using camel notation. The text property of the button is also changed. The code behind the button is accessed by double-clicking it, and the first output method, 'MessageBox', is introduced to display a message on the screen. The importance of not altering automatically generated code is highlighted.
The fundamental programming construct of 'sequence' is explained. Sequence means that statements in a program run one after another in the order they are written. This is demonstrated by displaying multiple messages sequentially, and then by changing the order of the commands to alter the display sequence.
An alternative, more modern way to display messages, 'MessageBox.Show', is introduced. The video notes that while 'MsgBox' is an older style, 'MessageBox.Show' represents an object-oriented approach and either can be used for now.
The concept of variables is introduced by adding a second button, 'btnVariables', to the form. A variable is defined as a temporary storage location in the computer's memory. The 'Dim' statement is used to declare a variable, specifying its name (e.g., 'stFirstName' using camel notation and a type prefix) and data type (e.g., 'As String'). The process of assigning a value to the variable is then demonstrated.
The video shows how to output the contents of a variable using 'MessageBox', emphasizing that no double quotes are used around the variable name. To create more friendly messages, string concatenation using the ampersand '&' operator is demonstrated, combining literal text with variable contents. The importance of adding spaces within literal strings for readability is also shown.
Another string variable, 'stLastName', is declared and assigned a value, which is then concatenated with the first name and other text. Common syntax errors related to missing ampersands and double quotes in concatenation are illustrated, highlighting the importance of matching pairs for these operators. A method to insert a space between two concatenated variables is also explained.
The video clarifies that variable declarations ('Dim' statements) can be placed anywhere before the variable is used, though it's good practice to place them at the top of a procedure. The temporary nature of variables is reiterated, explaining that memory is released when the program ends. Finally, the concept of a variable's contents changing during program execution is demonstrated by re-assigning new values to the existing variables and outputting them again, thus explaining why they are called 'variables'.