Presentation is loading. Please wait.

Presentation is loading. Please wait.

Additional Topics in VB.NET

Similar presentations


Presentation on theme: "Additional Topics in VB.NET"— Presentation transcript:

1 Additional Topics in VB.NET
Lecture 9 Additional Topics in VB.NET

2 Timer Control Invisible during runtime
Triggers an event after a specified period of time The Interval property specifies the time period – measured in milliseconds To begin timing, set the Enabled property to True To stop timing, set the Enabled property to False The event triggered each time is called Tick event

3 Timer Control (cont.) Interval property Enabled property Tick event
Between 0 and 65,535 milliseconds 1,000 milliseconds = 1 second Enabled property False (default) ==> Do not run Tick event True ==> Run Tick event at designated interval Tick event Runs each time the Timer's designated interval elapses, if Enabled = True

4 DateTimePicker & Calendar Controls
Takes less screen space Displays only day and date unless user drops down the calendar MonthCalendar Displays calendar Provide the ability to display calendars on your form

5 Calendar Controls (cont.)
DateTimePicker MonthCalendar

6 Getting Input from an Input Dialog Box
stringVar = InputBox(prompt, title) fileName = InputBox("Enter the name " _ & "of the file containing the " & _ "information.", "Name of File")

7 Using a Message Dialog Box for Output
Displays a message in a dialog box, waits for the user to click a button MsgBox(prompt) MsgBox("Nice try, but no cigar") MsgBox(prompt, , title) is executed, where prompt and title are strings, a message dialog box appears with prompt displayed and the title bar caption title and stays on the screen until the user presses Enter, clicks on the box in the upper-right corner, or clicks OK. For instance, the state-ment MsgBox("Nice try, but no cigar.", , "Consolation")

8 Some Built-In Functions
Example Input Output Int Int(2.6) is 2 number Chr Chr(65) is “A” string Asc Asc(“Apple”) is 65 Math.Round Math.Round(2.7) is 3 Math.Sqrt Math.Sqrt(9) is 3 Number number

9 Built-in Functions (2) Functions return a value
IsNumeric(9) ' Returns True IsNumeric(459.95) ' Returns True IsNumeric(“45 help”) ' Returns False

10 Input Validation Code If structure to determine if value falls within a range of acceptable values Refer to lab 6 – Calculate Grade Use single If for each value, Else for message to user, and execute Focus Method to reset focus to text box

11 Input Validation (2) Check to see if valid values were entered by user in TextBox and use Message Box to notify user if invalid IsNumeric function checks for numeric values If IsNumeric(txtQuantity.Text) Then ... Check for required data or not blank If txtName.Text <> "" Then ...

12 Variables Declaration: Assignment: Dim speed As Double speed = 50
Data type Variable name Assignment: speed = 50

13 Initial Value of a Integer
An integer is a whole number Declaring an integer variable: Dim varName As Integer (Numeric variables are automatically initialized to 0) To specify a nonzero initial value Dim varName As Double = 50

14 Initial Value of a String
By default the initial value is Nothing Strings can be given a different initial value as follows: Dim today As String = "Monday"

15 Incrementing To add 1 to the numeric variable var Or as a shortcut
var = var + 1 Or as a shortcut var +=1

16 Multiple Declarations
Dim a As Integer Dim b As Integer Alternative method: Multiple-declaration Dim a, b As Integer

17 ' Display the Hello World message
Remark Statement Also known as Comment, used for documentation Non-executable Automatically colored Green in Editor Begins with an apostrophe ( ' ) On a separate line from executable code At the right end of a line of executable code ' Display the Hello World message

18 lblMessage.Text=" Hello World "
Assignment Statement Assigns a value to a property or variable Operates from right to left Enclose text strings in quotation marks (" ") lblMessage.Text=" Hello World "


Download ppt "Additional Topics in VB.NET"

Similar presentations


Ads by Google