+Exercise 1.2.2:
In this exercises you will see two forms which is almost the same appearance except "Next" & "Back" buttons. After you see all attach code you will understand about the level of declaring a variable...
+Setting Properties:
-form:
Form1:
Name: frmInDe1
Caption: Increase/Decrease 1
Height: 2670
Width: 4515
Form2:
Name: frmInDe1
Caption: Increase/Decrease 2
Height: 2670
Width: 4515
-Commands:
Command 1 on Form 1 & Form 2:
Name: cmdIncrease
Caption: &Increase
Command 2 on Form 1 & Form 2:
Name: cmdDecrease
Caption: &Decrease
Command 3 on Form 1:
Name: cmdNext
Caption: &Next
Command 3 on Form 2:
Name: cmdBack
Caption: &Back
-Labels:
Label1 on Form 1 & Form 2:
Name: lblIncrease (optional)
Caption: Increase by 10
Label2 on Form 1 & Form 2:
Name: lblDecrease (optional)
Caption: Decrease by 10
-Text Boxs:
Text box1 on Form 1 & Form 2:
Name: txtIncrease
Text: " " // Leave it blank..!
Text box2on Form 1 & Form 2:
Name: txtDecrease
Text: " " // Leave it blank..!
+Attaching Codes:
-Form 1:
Option Explicit
Public x as Integer
------------------------------------
Private Sub cmdIncrease_Click()
x = x + 10
txtIncrease = x
End Sub
Private Sub cmdDecrease_Click()
x = x - 10
txtDecrease = x
End Sub
Private Sub cmdNext_Click()
frmInDe1.Hide
frmInDe2.Show
End Sub
-Form 2
Private Sub cmdIncrease_Click()
frmInDe1.x = frmInDe1.x + 10
txtInecrease = frmInDe1.x
End Sub
Private Sub cmdDecrease_Click()
frmInDe1.x = frmInDe1.x - 10
txtDecrease = frmInDe1.x
End Sub
Private Sub cmdBack_Click()
frmInDe1.Show
frmInDe2.Hide
End Sub
*We use keywords public for declare variable in Form 1 so we can use x that we declare in Form 1 in Form 2 by "Form1.x"


No comments:
Post a Comment