12
http://www.thayphet.net
Written by: Dương Thành Pht
Function giaithua(ByVal k As Integer)
Dim i As Integer, s As Long = 1
For i = 1 To k
s = s * i
Next
giaithua = s
End Function
Function tonggiaithua(ByVal x As Integer, ByVal y As Integer)
Dim i As Integer, s As Long = 0
For i = x To y
s = s + giaithua(i)
Next
tonggiaithuadayso = s
End Function
Private Sub cmdTonggiaithuadayso_Click(. . .)
Dim n As Integer, m As Integer
n = Val(txtson.Text)
m = Val(txtsom.Text)
txtketqua.Text = tonggiaithua(n, m)
End Sub
This is trial version
www.adultpdf.com
1313
Written by: Dương Thành Pht
http://www.thayphet.net
Truy0n tham s2 : Có 2 ki%u truyn tham s;: truyn theo
tham bi<n truyn theo tham tr=.
pháp :
[ByRef | ByVal] <tênbin> AS kiud! li"u
Truy3n theo tham tr+ (ByVal): M?i thay ñ@i chA di,n ra
trên bCn sao c6a tham s; chD không Cnh hưFng ñ<n
bi<n ñư#c truyn.
Truy3n theo tham bin(ByRef): Khi truyn theo tham
bi<n, các thay ñ@i trên tham s; trong chương trình con
Cnh hưFng trHc ti<p ñ<n tham s; thHc.
This is trial version
www.adultpdf.com
1414
Written by: Dương Thành Pht
http://www.thayphet.net
Khi truyn tham tr=, m?i thay
ñ@i chA di,n ra trên bCn sao
c6a tham s; chD không Cnh
hưFng ñ<n bi<n ñư#c truyn.
Khi truyn theo tham bi<n Các
thay ñ@i trên tham s; trong hàm
con Cnh hưFng trHc ti<p ñ<n
tham s; ñư#c truyn
txtTruochoanviA1
txtTronghoanviA1
txtSauhoanviA1
txtTruochoanviA2
txtTronghoanviA2
txtSauhoanviA2
txtSoa
txtSob
This is trial version
www.adultpdf.com
1515
Written by: Dương Thành Pht
http://www.thayphet.net
‘Tham s@ tham tr+
Sub HoanVi1(ByVal a As Integer, ByVal b As Integer)
Dim tam As Integer
tam = a
a = b
b = tam
txtTronghoanviA1.Text = a
txtTronghoanviB1.Text = b
End Sub
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
‘Tham s@ tham bin
Sub HoanVi2(ByRef a As Integer, ByRef b As Integer)
Dim tam As Integer
tam = a
a = b
b = tam
txtTronghoanviA2.Text = a
txtTronghoanviB2.Text = b
End Sub
This is trial version
www.adultpdf.com
1616
Written by: Dương Thành Pht
http://www.thayphet.net
Private Sub btXemketqua_Click( . . .)
Dim a As Integer, b As Integer
a = Val(txtSoa.Text)
b = Val(txtSob.Text)
'Truyen tham so la tham bien
txtTruochoanviA1.Text = a
txtTruochoanviB1.Text = b
HoanVi1(a, b)
txtSauhoanviA1.Text = a
txtSauhoanviB1.Text = b
'Truyen tham so la tham tri
txtTruochoanviA2.Text = a
txtTruochoanviB2.Text = b
HoanVi2(a, b)
txtSauhoanviA2.Text = a
txtSauhoanviB2.Text = b
End Sub
This is trial version
www.adultpdf.com