Presentation is loading. Please wait.

Presentation is loading. Please wait.

Fundamentals of Programming in VB.Net

Similar presentations


Presentation on theme: "Fundamentals of Programming in VB.Net"— Presentation transcript:

1 Fundamentals of Programming in VB.Net
VB.NET Events An Event Procedure Walkthrough Properties and Event Procedures of the Form The Declaration Statement of an Event Procedure 2/24/2019 Fundamentals of Programming in VB.Net

2 Fundamentals of Programming in VB.Net
What is an event? An event is an action, such as the user clicking on a button Usually, nothing happens until the user does something and generates an event 2/24/2019 Fundamentals of Programming in VB.Net

3 Fundamentals of Programming in VB.Net
VB.NET program: Create the interface; that is, generate, position, and size the objects. Set properties; that is, configure the appearance of the objects. Write the code that executes when events occur. This block of code is called event procedure. 2/24/2019 Fundamentals of Programming in VB.Net

4 Fundamentals of Programming in VB.Net
Event Procedures Private Sub objectName_event( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles objectName.event statements End Sub Private Sub ObjectName_event(…) Handles objectName.event Because the book does not make use of the parameter list, it is replaced with an ellipsis 2/24/2019 Fundamentals of Programming in VB.Net

5 Fundamentals of Programming in VB.Net
Statements Properties of controls can be changed both in the Properties window and in the statements of the event procedure. The statement we use to change the property value is call an Assignment statement 2/24/2019 Fundamentals of Programming in VB.Net

6 Fundamentals of Programming in VB.Net
Changing Properties Properties are changed in code with the following: controlName.property = setting This is an assignment statement txtBox.ForeColor = Color.Red Me.Text = "Demonstration“ Instead of (VB.6) Form1.Text = "Demonstration" The form is referred to by the keyword Me. The setting value on the right hand side of the equal sign is being assigned to the property of the control listed on the left hand side of the equal sign 2/24/2019 Fundamentals of Programming in VB.Net

7 Fundamentals of Programming in VB.Net
Program Region 2/24/2019 Fundamentals of Programming in VB.Net

8 Dropdown Boxes Automatically pops up to give the programmer help.
2/24/2019 Fundamentals of Programming in VB.Net

9 Fundamentals of Programming in VB.Net
Help Help menu Press ALT/H/I - Help index window Dynamic help – samples (Member Listing) Type dot “.” following a word Type parenthesis following a word Context-sensitive help Place cursor on the word, and press F1 2/24/2019 Fundamentals of Programming in VB.Net

10 Fundamentals of Programming in VB.Net
Event Outcomes Private Sub txtFirst_TextChanged(...) Handles txtFirst.TextChanged txtFirst.ForeColor = Color.Blue End Sub Private Sub btnRed_Click(...) Handles btnRed.Click txtFirst.ForeColor = Color.Red Private Sub txtFirst_Leave(...) Handles txtFirst.Leave txtFirst.ForeColor = Color.Black 2/24/2019 Fundamentals of Programming in VB.Net

11 The Declaration Statement of an Event Procedure
A declaration statement for an event procedure: Private Sub btnOne_Click(...) Handles btnOne.Click The name can be changed at will. Private Sub ButtonPushed(...) Handling more than one event: Handles btnOne.Click, btnTwo.Click btnOne_Click is the name of the event procedure, and btnOne.Click identifies the event that triggers the procedure Also, an event procedure can be triggered by more than one event. 2/24/2019 Fundamentals of Programming in VB.Net


Download ppt "Fundamentals of Programming in VB.Net"

Similar presentations


Ads by Google