Visual Basic Programming: By: Rzgar Ali
Visual Basic Programming: By: Rzgar Ali
Programming
By : Rzgar Ali
What is a programming
Aprogramming
language? languageis, as the name would suggest,
Compiler
data type
a particular kind of data item, as defined by
The following table shows the Visual Basic data types, their supporting
common language runtime types, their nominal storage allocation, and
their value ranges.
1 bit
0=0
1=1
2 bit
00 =
0
01 =
1
10 =
VARIABLES
Variables are inserted as code statements.
VARIABLE Declarations
It is advisable to declare all variables before
they are used in a program.
Using the DIM statement to declare variables by
assigning them a name and a data type. Below
is the format of the DIM statement in a variable
declaration.
Syntax Errors
Run-Time Errors
Logic Errors
Syntax errors are those that appear while you write code. Visual Basic
checks your code as you type it in the Code Editor window and alerts you if
you make a mistake, such as misspelling a word or using a language
element improperly. Syntax errors are the most common type of errors. You
can fix them easily in the coding environment as soon as they occur.
System_CAPS_ICON_note.jpg Note
The Option Explicit statement is one means of avoiding syntax errors. It
forces you to declare, in advance, all the variables to be used in the
application. Therefore, when those variables are used in the code, any
typographic errors are caught immediately and can be fixed.
Run-time errors are those that appear only after you compile and run your
code. These involve code that may appear to be correct in that it has no
syntax errors, but that will not execute. For example, you might correctly
write a line of code to open a file. But if the file is corrupted, the application
cannot carry out the Open function, and it stops running. You can fix most
run-time errors by rewriting the faulty code, and then recompiling and
rerunning it.
Logic errors are those that appear once the application is in use. They are
most often unwanted or unexpected results in response to user actions. For
example, a mistyped key or other outside influence might cause your
application to stop working within expected parameters, or altogether. Logic
errors are generally the hardest type to fix, since it is not always clear