Sei sulla pagina 1di 5

Lo que haya despus de comilla se ignora

________________________________________________________________________________
________________________________________________________________________________
_____________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________
_____________________________________________________________________________
ARRAYS AND VARIABLES
indexnumber(0-length)
Variables can have a local (functions and subs) or global (main body) scope
Option Explicit
This shows an error message if you use a
variable without declaring it before.
Dim var(length)
ength)
ReDim [preserve] varname(subscripts)
ame values are saved)

(it can be declared without a specific l


(if it's written preserve, previous varn

public/private var1,var2,...
variables by writting this

You can explicitly declare global/local

________________________________________________________________________________
________________________________________________________________________________
_____________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________
_____________________________________________________________________________
DATA TYPES
Numeric Integer, Double
String ""
Date
#1/3/2002#
#January 3, 2001#
3, 2001 22:30:10#
Time
#22:30:10#
#10:30:10 PM#
Boolean

#3 January, 2001#

#January

AUTOMATIC CONVERSION
Number + or String If the string represents a number, it is converte
d to a number and the result is a number. Otherwise, the program stops with an e
rror message
Date/time + or - Number The whole (integer) part of the number is added to the d
ate as a number of days.Any fractional part of the number is added as a time off
set, as a fraction of a day.
Date + or String If the string represents a number, it is converte
d to a number and the result is a date. Otherwise, an error occurs.
Anything & Anything
Values of any type are converted to strings, and the str
ings are concatenated.
________________________________________________________________________________
________________________________________________________________________________
_____________________________________________________________________________

________________________________________________________________________________
________________________________________________________________________________
_____________________________________________________________________________
CONSTANTS
const variable=value

variable no puede cambiar a lo largo del programa

________________________________________________________________________________
________________________________________________________________________________
_____________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________
_____________________________________________________________________________
OPERATORS
<>
is
&
Mod
>=

Not equal to
Object equivalence
String concatenation(any type of value)(sometimes + can also be used)
Modulus
Greater than or equal

not
and
se
or
xor
eqv
imp

Negation not
Conjunction

(3 = 4) -True
(3 = 4) and (3 < 4) -Fal

Disjunction
Exclusion (different)
Equivalence (same)
Implication (same value or second value True)

(3 = 4) or (3 < 4) -True
true xor true -False
false eqv false -True
false imp true -True

________________________________________________________________________________
________________________________________________________________________________
_____________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________
_____________________________________________________________________________
LOOPS
if ...(==/===) then ... elseif... else ... end if
for i=n to m each variable in variablevector... next
for counter = startvalue to endvalue step stepvalue(integer)
Exit for
(variable defined) select case variable case value1: statements case value2: ...
do while/until condition statements loop
(Parenthesis are used only when all things are on the same line)
do statements loop while/until (conditions) (statements are executed at least on
ce)
Exit Do (exit from a loop)
________________________________________________________________________________
________________________________________________________________________________
_____________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________

_____________________________________________________________________________
FUNCTIONS
If we aren't using the value which a function is going to give us, or if functio
n doesn't need any argument
->
we don't need to write parentheses
________________________________________________________________________________
________________________________________________________________________________
_____________________________________________________________________________
[PROCEDURES:FUNCTIONS AND SUBROUTINES (subroutines doesn't return values)]
function name (arguments) statements end function
sub name (arguments) statements end sub
________________________________________________________________________________
________________________________________________________________________________
_____________________________________________________________________________
[DATE AND TIME]
Date() and Time()
The date is stored as an integer number
of days since January 1, 0099, and times are stored as decimal fractions of a da
y (1 second equals 0.0000115741) You can operate them as integers.
DateAdd(interval, number, date)
It adds time to a given date
DateDif(interval, date1, date2)
It gives the number of "interval" betwee
n two dates
Day(date)
The day of the month of the given date f
rom 1 to 31.
Weekday(date)
The day of the week of the given date as
a number from 1 to 7, where 1 equals Sunday, 2 equals Monday, and so on.
Month(date)
The month of the given date, where 1 equ
als January and so on.
WeekdayName(date)
The day of the week of date as a string.
MonthName(date)
The name of the month in which date fall
s.
Hour(time)
The hour (0 to 23) of the given time.
Minute(time)
The minute (0 to 59) of the given time.
Second(time)
The second (0 to 59) of the given time.
Date(time)
With an argument, Date returns just the
date part of a date/time value, effectively, midnight of the specified date.(Wit
hout an argument, Date returns today s date).
Time(time)
With an argument, Time returns just the
time part of a date/time value. (Without an argument, Time returns the current t
ime).
Now()
Current date-time
-IntervalYYYY Years
Q Quarters

M Months
W Weeks

D Days
H Hours

N Minutes
S Seconds

________________________________________________________________________________
________________________________________________________________________________
_____________________________________________________________________________
[STRING-MANIPULATION]
InStr(n, filename, .DAT )
0 if there is nothing before ".DAT" and it's the number
of character where ".DAT" starts if there is it (With TEST.DAT, it would give us
5) This function is case sensitive. It starts searching from char n.
InStrRev( ABCABC , AB )
It does the same as before but starting the search from
the right
Len(string)
Lcase(string)
Ucase(string)
Trim(string)
Ltrim(string)
Rtrim(string)

The length of string in characters


lowercase
uppercase
leading and trailing spaces removed
leading spaces removed
trailing spaces removed

-Extracting charactersLeft(string, length)


Right(string, length)
Mid(string,start)
t onward
Mid(string,start,length)

The leftmost length characters from string


The rightmost length characters from string
That part of string from character position star
length characters of string from position start

-Converting stringcstr(value)
A string representation of value.
clng(value)
string to a long (32-bit) integer.
cdbl(value)
to a double-precision floating point value.
cdate(value)
to a date-time value.
chr(value)
Returns a one-character string containg the char
acter corresponding to the integer ASCII value.
asc(string)
Returns the ASCII value of the first character i
n the string.
________________________________________________________________________________
________________________________________________________________________________
_____________________________________________________________________________
[I/O]
-MsgBoxMsgBox("msg",buttons(+type),title)
lick the button
BUTTONS:

Script secuence doesn't work until you c

VbOKOnly
VbOKCancel
VbAbortRetryIgnore
VbYesNoCancel
VbYesNo
VbRetryCancel

0
1
2
3
4
5

OK button
OK and Cancel buttons
Abort, Retry, and Ignore buttons
Yes, No, and Cancel buttons
Yes and No buttons
Retry and Cancel buttons

16
32
48
64

Critical Message icon


Question icon
Exclamation icon
Information icon

TYPE:
VBCritical
VBQuestion
VbExclamation
VBInformation
RETURN:
VbOK
VbCancel
VbAbort
vbRetry
vbIgnore
VbYes
VbNo

1
2
3
4
5
6
7

-InputBoxInputBox(msg, title, defaultinbox)


either number or string

Value given by user can be used

________________________________________________________________________________
________________________________________________________________________________
_____________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________
_____________________________________________________________________________
ERROR HANDLING
on error resume next
File is executed despite errors(
second time it is written it restores default behaviour(stops if there is some e
rror))
err.number
err.description

Potrebbero piacerti anche