Vous êtes sur la page 1sur 5

Visual Basic

Syntax and Data Types


Rules for naming constants, variables, and sub procedures

Syntax They must begin with a letter. They can't contain embedded periods or type-declaration characters (special characters that specify a data type). They can be no longer than 255 characters. The names of controls forms classes and modules must not exceed !" characters. They can't be the same as restricted #eywords (e.g. $f %bs or &').

Constant
Syntax for declaring a constant is( )Public|Private Const constantname )!s type* + expression ,xamples( Const conPi " #$%&%'()*'#'+(,( Public Const con-axPlanets !s .nteger " ( -ariables are a storage location and allow us to store data and retrie.e it. -ariables in -/ start with the Dim #eyword.

Syntax for 0efining -ariable 1ame and Type Dim variablename )!s type* ,x ( 0im numberofStudent %s integer

,mbedded 2omments The comment symbol for the .isual /asic is the Single /uote 012$

,x(

3This is a comment beginning at the left edge.

The two main structures for building procedures4


Sub Procedures 3unction Procedures

Sub Procedures The syntax for the sub procedures is4 )5ri.ate65ublic*)Static*Sub procedurename(arguments) statements ,nd Sub

3unction Procedures The syntax for the 7unction procedures is4 4Private|Public 4Static 3unction procedurename(arguments))!s type* statements 5nd 3unction

Data Types

Vous aimerez peut-être aussi