|
Simple
Example - Subroutines
VB
Code
|
Sub sub1(a, b,
c)
If Cond Then
Statements
Else
Exit Sub
End If
End Sub
Subroutine sub2(d, e)
sub1 d, e, d+e
call sub1 d, e, d+e
End Sub
|
Python
Code
|
def
sub1(a, b, c):
if Cond:
Statements
else:
return
def sub2(d, e):
sub1(d, e, d+e)
sub1(d, e, d+e) |
Simple
Example - Functions
VB
Code
|
Function sub1(a,
b, c)
sub1 = c
If Cond Then
sub1 = a+b
Else
Exit Function
End If
End Sub
Function sub2(d, e)
sub2 = sub1(d, e, d+e)
End Sub
|
Python
Code
|
def
sub1(a, b, c):
_retval = c
if Cond:
_retval = a+b
else:
return _retval
return _retval
def sub2(d, e):
_retval = sub1(d, e, d+e)
return _retval |
Harder
Example - Optional Arguments
VB
Code
|
Sub sub1(Optional
a, Optional b, Optional c, Optional d)
If IsMissing(d) Then d = 20
If Cond Then
Statements
Else
Exit Sub
End If
End Sub
Subroutine sub2(d, e)
sub1 b:=a, d:=d
End Sub
|
Python
Code
|
def
sub1(a=None, b=None, c=None, d=20):
if Cond:
Statements
else:
return
def sub2(d, e):
sub1(b=a, d=d) |
|