Visual Basic - Language Syntax - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

Visual Basic - Language Syntax

Description:

Visual Basic - Language Syntax. CIS 241 - Advanced Visual Basic. Data ... Visual Basic Functions. Numeric. String. Determining Data Type. Date/Time. Format ... – PowerPoint PPT presentation

Number of Views:113
Avg rating:3.0/5.0
Slides: 15
Provided by: curt3
Category:

less

Transcript and Presenter's Notes

Title: Visual Basic - Language Syntax


1
Visual Basic - Language Syntax
  • CIS 241 - Advanced Visual Basic

2
Data Types
  • Integer Types (int)
  • Real Types (sng, dbl)
  • String (str)
  • Boolean (bln)
  • Date/Time (dtm)
  • Currency (cur)

3
Variables
4
Variables/Constants Declared and Assigned
  • Dim count as Integer
  • Public name as String
  • Private total as Integer
  • Assignment
  • count 100
  • name Bob
  • Constants
  • const strName as String Mary

5
Operators
  • Arithmetic
  • Relational
  • Logical
  • String

6
Control Structures - Selection
  • If condition Then
  • statements
  • End if
  • If condition Then
  • statements
  • Else
  • statement s
  • End if
  • The ifs may be nested

7
Control Structures - Selection
  • Select Case expression
  • case value1
  • statements
  • case value2
  • statements
  • ..
  • case else
  • statements
  • End Select

8
Control Structures - Repetition
  • Do While Until condition Pre Test
  • statements
  • Loop
  • Do Post Test
  • statements
  • Loop While Until condition
  • For
  • For variable init To final step step_size
  • statements
  • Next

9
Functions/Subroutines
  • Public Private Function Name(Args) as
    DataType
  • Name return value
  • End Function
  • Public Private Sub Name(Args)
  • ...
  • End Sub

10
Arguments to Routines
  • By value
  • By reference (default)
  • Private Function Multiply(ByVal X as Integer, _
  • ByVal Y as Integer) as Integer
  • Private Sub InOut(ByVal X as Real, Y as Real)

11
Visual Basic Functions
  • Numeric
  • String
  • Determining Data Type
  • Date/Time
  • Format

12
Arrays - Declaring an Array
  • Dim Name(numofElem) as DataType
  • Number of Elements
  • 5
  • 1 to 5
  • Multidimensional use multiple sizes
  • (1 to 3, 1 to 5)

13
Arrays - Using Arrays
  • Dim scores(1 to 20) as Integer
  • Dim I as Integer
  • For I 1 to 20
  • scores(I) 0
  • Next

14
With
  • May be used to access several parts of an object
  • Syntax
  • With objName
  • ..
  • End With
  • With txtString
  • .Text Hello
  • .FontSize 12
  • End With
Write a Comment
User Comments (0)
About PowerShow.com