Function Example
Sub CATMain()
Dim Box
Box = MsgBox(Multiplication(1, 3))
End Sub
Function Multiplication(I, II)
Multiplication = I * II
End Function
================================================
Sub Routine Example
Sub CATMain()
Multiplication 1,3
End Sub
Sub Multiplication(I, II)
Dim Box
Box = MsgBox(I * II)
End Sub
=================================================
If - Else /And /Or
Sub CATMain()
Dim A,B
A =2
B =2
If (A >= 1) And (B=1) Then
MsgBox("C = 2")
MsgBox("D = 1")
Else
MsgBox (A*B)
End If
End Sub
-------------------------------------------
Sub CATMain()
Dim A,B
A =2
B =2
If (A >= 1) Or (B=1) Then
MsgBox("C = 2")
MsgBox("D = 1")
Else
MsgBox (A*B)
End If
End Sub
==============================================
Select Case Else
Sub CATMain()
Dim Input
Input = Inputbox("Enter number between 0-2:",0)
Select Case Input
Case "0"
MsgBox("Number =0")
Case "1" , "2"
MsgBox("Number>0")
Case Else
MsgBox ("Wrong input")
End select
End Sub
=============================================
For-Next Case
Sub CATMain()
Dim I, Sum
Sum=0
For I =0 To 10 Step 1
Sum = Sum + I
Next
MsgBox (Sum)
End Sub
==============================================
Do-While Case
Sub CATMain()
Dim I, Sum
Sum=0
Do While Sum < 100
Sum = Sum + I
I=I+1
Loop
MsgBox (Sum)
End Sub
===============================================
Do-Until Case
Sub CATMain()
Dim I, Sum
Sum=0
Do
Sum = Sum + I
I=I+1
Loop Until (Sum>60) Or (I>10)
MsgBox (Sum)
End Sub
===============================================
Object-Method-Class
Print document name & part name
Sub CATMain()
Dim Part
Dim Doc
Set Doc = CATIA.ActiveDocument
Set Part = Doc.Part
MsgBox(Doc.Name)
MsgBox(Part.Name)
End Sub