Download presentation
Presentation is loading. Please wait.
Published byMarion Franklin Modified over 9 years ago
1
Visual Basic.NET Programming for the Rest of Us Keith Mulbery Utah Valley State College
2
Visual Basic.NET2 Object-Oriented Programming (OOP) Centered on object creation. Object: element containing data & actions Examples Form (window) object Label (descriptions) object Text Box (data entry) object Button (event driven) object Attributes (Properties) Text property (e.g., Hourly Pay Rate) Size (Height & Width) Location (Vertical & Horizontal Position)
3
Visual Basic.NET3 Event-Driven Programming Responds to events Action takes place in the program. User Action Examples Click or double-click a button Press a key on the keyboard System Occurrences Examples Timer Sits idle until an event occurs—again program responds to user (or system).
4
Visual Basic.NET4 Getting Started Sets up folder to store project; creates project With same filename Specifies drive and main folder to create program folder Shows path to project
5
Visual Basic.NET5 Visual Basic.NET Interface Mouse over to see Toolbox Form (interface) Design window (displays form) Form(s) within Solution Explorer Property window for selected object (currently the form) Project name Click to show properties in alpha order
6
Visual Basic.NET6 Form Properties Text Appears on title bar StartPosition Form location onscreen MaximizeBox and MinimizeBox True (Default) False (Dims or hides) Icon Symbol in top left corner (left of Text property)
7
Visual Basic.NET7 ToolBox UnpinnedPinned (stays onscreen)
8
Visual Basic.NET8 Controls (Objects) ControlPrefixExampleDescription FormfrmfrmMainGUI interface ButtonbtnbtnCloseRectangular object that triggers event procedure when clicked GroupgrpgrpInputBorder to organize controls LabellbllblGrossPayBox displaying text that user can’t change (descriptions & output) TexttxttxtPayRateRectangular area for data input by user
9
Visual Basic.NET9 Program Interface 2 Group Boxes 8 Labels 5 Descriptive 3 Output 2 Text Boxes 3 Buttons
10
Visual Basic.NET10 Control Name Properties txtHourlyRate txtHoursWorked lblGrossPay lblTaxes lblNetPay btnCalculate btnClear btnExit
11
Visual Basic.NET11 Text Property & Access Keys Shows up on the interface Uses & symbol to create access key Examples &Calculate E&xit Only 1 letter per Text property No duplicate access keys on a form (see also Tab Order in slide show)
12
Visual Basic.NET12 Format Menu Options
13
Visual Basic.NET13 Tab Order Controls order of which control has focus when user presses Tab or presses Alt and the access key Goes from descriptive label to text box
14
Visual Basic.NET14 Event Procedure Algorithm that executes when the event occurs. Not triggered until event occurs.
15
Visual Basic.NET15 Begin Program Input hourly rate Input # of hours worked Are the # of hours > 40? No Multiply the hours worked by the hourly rate. Yes Multiply 40 by the hourly rate to get the regularly weekly pay. Subtract 40 from the total hours worked to find the OT hours. Multiply the pay rate by 1.5 to get the OT rate. Multiply the OT hours by the OT rate to get the amount of OT pay. Add the regular weekly pay and the OT pay. Display gross pay End Program
16
Visual Basic.NET16 Begin Program Input hourly rate Input # of hours worked Are the # of hours > 40? No Multiply the hours worked by the hourly rate. Yes Multiply 40 by the hourly rate to get the regularly weekly pay. Subtract 40 from the total hours worked to find the OT hours. Multiply the pay rate by 1.5 to get the OT rate. Multiply the OT hours by the OT rate to get the amount of OT pay. Add the regular weekly pay and the OT pay. Display gross pay End Program
17
Visual Basic.NET17 Exit Event Procedure Keywords in blue Control name Event Keyword that terminates the program Comments document (explain the program); use plenty of them; start with an apostrophe; appear in green
18
Visual Basic.NET18 Clear Button Event Pseudocode
19
Visual Basic.NET19 Clear Event Procedure Clear user input (text boxes) txtBoxName.Clear Clear output (labels) lblLabel.Text=“” Set focus to the 1st text box for for next transaction
20
Visual Basic.NET20 Constants and Variables Constant Value that does not change (such as tax rate) Declare to avoid magic numbers (typed numbers in statements) Variables Memory locations that hold data that can change during the program’s operation Use to store input, manipulate, and hold resulting values
21
Visual Basic.NET21 Data Types Numeric Double Single Integer Decimal String
22
Visual Basic.NET22 Constant Declaration Const dblLOW_TAX_RATE As Double = 0.15 Const is keyword for Constant dbl is data type prefix LOW_TAX_RATE is descriptive name; all caps with underscores As Double is the data type declaration 0.15 is the number
23
Visual Basic.NET23
24
Visual Basic.NET24 Variable Declaration Dim dblHourlyRate As Double Dim stands for “Dimension” dbl is the data type prefix for Double HourlyRate is descriptive name; use camel casing; not all caps; no underscores As Double is the data type
25
Visual Basic.NET25
26
Visual Basic.NET26 Variable Assignment Get user input Store as a value into a numeric variable
27
Visual Basic.NET27 If Statements If condition Then statement block if condition is true Else statement block if condition is false End If Condition Logical Test sngHours <= intBASE_HOURS
28
Visual Basic.NET28 Calculate Gross Pay Use line continuation character (space and _) to word-wrap statements for readability Use mathematical operators (* / + -) Apply order of precedence Group by parentheses
29
Visual Basic.NET29 Determine Tax Rate & Tax Amount $0 to $40015% $400.01 to $75022% $750.01 and up30%
30
Visual Basic.NET30 Calculate Net Pay Subtract the contents of the dblTaxes variable from the contents of the dblGrossPay variable Store result in dblNetPay variable
31
Visual Basic.NET31 Display Output in Output Labels Display output in label Text properties Format the output for currency
32
Visual Basic.NET32 GotFocus Event Procedure For each text box—selects existing contents (white on blue)
33
Visual Basic.NET33 Message Boxes Display information (such as error messages) to the user MessageBox.Show("Message","Caption",Buttons,Icon) Message—what you want to say to user Caption—what appears on the title bar Buttons—what buttons, such as OK, to appear Icon—visual symbol
34
Visual Basic.NET34 MessageBox.Show("Message","Caption",Buttons,Icon) MessageBoxIcon.Information MessageBoxIcon.Asterisk MessageBoxIcon.Error MessageBoxIcon.Stop MessageBoxIcon.Warning MessageBoxIcon.Exclamation MessageBoxIcon.Question
35
Visual Basic.NET35 Validation Procedure
36
Visual Basic.NET36 Call Validation Procedure In event procedure, after declarations, but before assignments Boolean variable (True or False); set it as a flag that there is a problem
37
Visual Basic.NET37 Form Naming Project>Properties
38
Visual Basic.NET38 Add New Form for Splash Screen Click Add New Item on toolbar. Keep the.vb extension
39
Visual Basic.NET39 Form Load for Main Form
40
Visual Basic.NET40 Splash Screen TopMost Property: True Timer Control Enabled Property: True Interval Property: 3000
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.