You are on page 1of 4

) ( ... ) ( 2 ) ( 2 ) ( 2 .....

) (
2
) ( ) (
2
) (
1 1
1
1
1
b f x f x f x f a f
x
x f x f
x
dx x f
i i i
N
i
i i
b
a


)} ( ) ( 4 ) ( 2
..... ) ( 2 ) ( 4 ) ( 2 ) ( 4 ) ( {
3
) (
3
) (
1 1
4 3 2 1
1
b f x f x f
x f x f x f x f a f
x
x f w
x
dx x f
n n
N
i
i i
b
a

Numerical integration and differentiation


x
y y
dx
dy

1 0
x
y y
dx
dy

0 1
x
y y
dx
dy


2
1 1
Some VBA Syntax:
Rule #1: Referring to the Property of a object
Range(A4).Value
Range(A4).Offset(3,2)
Rule #2: Changing the property of an object
Range(A4).Value=25
Rule #3: Returning the current value of object property
cellValue=Range(A4).Value
Rule #4: Referring to the objects Method
Range(A4).ClearContents
Some VBA built-in function
ABS(x) - Absolute value of x
ATN(x) - ArcTangent
TAN(x) - Tangent x in RADIANS
EXP(x) - e to the power of x
LOG(x) - natural log.
SQR(x) - square root
b Mod a - remainder when dividing b by a
Some Excel functions
PI(), Sqrt(value), countif, lookup, FREQUENCY(data_array,bins_array)
Slope(y-value,x_value), Intercept (y-value,x_value)
Linest and Logst
More VB functions and Syntax:
Sqr(value)
If ( condition ) Then
( execution1 )
Elseif ( condition ) Then
( execution2 )
Else
( execution3 )
End If
Select case testexpression
[case expressionlist1
[statement] ]
[case expressionlist2
[statement] ]
[case else
[statement] ]
End select
For LoopIndex=startValue To endValue [Step Increment]
(body of loop)
Next [loopIndex]
Do
(body of loop)
Loop until (condition to stop the loop)
Exit for, Exit do, Exit Sub
Open Pathname For mode As [#]filenumber
Write #filenumber, [Outputlist]
Close #filenumber
Open Pathname For mode As [#]filenumber
Input #filenumber, Varlist
Close #filenumber
EOF (filenumber)
Function Description
InStr(string1, string2)
LCase(string)
Left(string, length)

Len(string)
LTrim(string)
Mid(string, Start[,length])
Right(string,length)
RTrim(string)
Space(number)
Str(number)
Trim(string)
UCase(string)
Val(string)
Returns the position of string 1 within string2
Converts string to lowercase
Returns a specified number of characters(length) from
the left side of string
Returns the number of characters in string
Returns string without leading spaces
Returns length characters from string, beginning at start
Returns length characters from right side of string
Returns string without trailing spaces
Returns string consisting of number spaces
Returns string representation of number
Returns string without leading and trailing spaces
Converts string to uppercase
Returns the number contained in string as a numerical
values

v =MsgBox prompt[,button][,title][,helpfile, context]
0 - OK button only (default)
1 - OK and Cancel
3 - Yes, No and Cancel
v=InputBox(prompt[, title][,default])
prompt - Message in the dialog box
title - Title in title bar of message box
default - string expression in the text box as the default response
DIM array_name ([min TO] max) as data_type
Some VB functions and Syntax (continue):
expression.GetOpenFilename(FileFilter, FilterIndex, Title, ButtonText,
MultiSelect)
expression Required. An expression that returns an Application object.
FileFilter Optional Variant. A string specifying file filtering criteria.
MultiSelect Optional Variant. True to allow multiple file names
Example:
fileToOpen=Application _
.GetOpenFilename("Text Files (*.txt), *.txt")
If fileToOpen<>False Then
MsgBox "Open " & fileToOpen
End If
fileSaveName =Application _
.GetSaveAsFilename( _
fileFilter:="Text Files (*.txt), *.txt")
If fileSaveName <>False Then
MsgBox "Save as " & fileSaveName
End If
Some VB functions and Syntax (continue):
IsNumeric(expression)
Format(8315.4, " 00000.00" ) 08315.40
Format(8315.4, " #####.##" ) 8315.4
Format(8315.4, " Scientific" ) 8.31E+3
Control Default Property
Text Box Text
Command Buttons Value
Label Caption
Frame Caption
Check Box Value
Option Button Value
Clearing Text Boxes and Labels (null String)
Resetting Focus (setFocus)
Setting the Value Property
option Buttons/Check boxes
Changing Font Property of Controls
(TxtName.Font.Bold=true, TxtName.Font.Size=12, etc)
Changing Color of Text (txtname.foreColor =vbRed)
Changing Multiproperty of a control (With, End With)
Concatenating Text (String1&Opbect.Text&string2...)

You might also like