Thursday, July 8, 2010
My Visual Basic 6.0 (Chapter 01-Ex1.2.1)
+Exercise 1.2.1:
HI! In this exercises you will understand about the difference between local and global variable....
+Setting Properties:
-form:
Name: frmInDe
Caption: Increase/Decrease
-Commands:
Command 1:
Name: cmdIncrease
Caption: &Increase
Command 2:
Name: cmdDecrease
Caption: &Decrease
-Labels:
Label1:
Name: lblIncrease (optional)
Caption: Increase by 10
Label2:
Name: lblDecrease (optional)
Caption: Decrease by 10
-Text Boxs:
Text box1:
Name: txtIncrease
Text: " " // Leave it blank..!
Text box2:
Name: txtDecrease
Text: " " // Leave it blank..!
+Attaching Codes:
-Declaring Variable in Global:
Option Explicit
Dim x as Integer
------------------------------------
Private Sub cmdIncrease_Click()
x = x + 10
txtIncrease = x
End Sub
Private Sub cmdDecrease_Click()
x = x - 10
txtIncrease = x
End Sub
-Declaring Variable in Local:
Private Sub cmdIncrease_Click()
Static x as Integer
x = x + 10
txtIncrease = x
End Sub
Private Sub cmdDecrease_Click()
Static x as Integer
x = x - 10
txtDecrease = x
End Sub
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment