You are on page 1of 8

College of Computing Studies

Lesson #7 – Multiple Activities

Main Module Pizza Module Drinks Module

Things to do.
1. On Main module click Project →Add New Module →Activity Module. Enter “Pizza” as
module name.
2. Add another activity module and name it as “Drinks”.
3. On Visual Designer, add new layout by clicking File →New and save it as “laypizza”.
4. Add another layout and name it as “laydrinks”.

JBQ@2021
College of Computing Studies

5. Click File on Visual Designer and you will see all the layouts. Click “Layout” and add all
the controls used in designer below and save the layout.

6. Click File and open the laypizza layout. Add all controls used in designer below and save
the layout.

JBQ@2021
College of Computing Studies

7. Click File and open the laydrinks layout. Add all controls used in designer below and
save the layout.

Codes for Main Module

Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private xui As XUI
Dim priceforpizza As String
Dim pricefordrinks As String

End Sub

Sub Globals
'These global variables will be redeclared each time the activity is created.
Private txtpricepizza As EditText
Private txtpricedrinks As EditText

JBQ@2021
College of Computing Studies

Private txttotal As EditText


End Sub

Sub Activity_Create(FirstTime As Boolean)


Activity.LoadLayout("Layout")
End Sub

Sub Activity_Resume
txtpricepizza.Text = priceforpizza
txtpricedrinks.Text = pricefordrinks
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Private Sub btnPizza_Click


StartActivity(Pizza)
End Sub

Private Sub btnDrinks_Click


StartActivity(Drinks)
End Sub

Private Sub btntotal_Click


txttotal.Text = txtpricepizza.Text + txtpricedrinks.Text
End Sub

Codes for Pizza Module

Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.

End Sub

Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.

JBQ@2021
College of Computing Studies

Private chkham As CheckBox


Private chkhaw As CheckBox
Private chkpep As CheckBox
Private txtprice As EditText
End Sub

Sub Activity_Create(FirstTime As Boolean)


'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("laypizza")

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Private Sub btnHome_Click


Activity.Finish
End Sub

Private Sub btngotodrinks_Click


StartActivity(Drinks)
End Sub

Private Sub btnclear_Click

chkham.Checked = False
chkhaw.Checked = False
chkpep.Checked = False
txtprice.Text = 0
End Sub

Private Sub chkpep_CheckedChange(Checked As Boolean)


If chkpep.Checked = True Then
txtprice.Text = txtprice.Text + 400
Else
txtprice.Text = txtprice.Text - 400
End If
End Sub

JBQ@2021
College of Computing Studies

Private Sub chkhaw_CheckedChange(Checked As Boolean)


If chkhaw.Checked = True Then
txtprice.Text = txtprice.Text + 300
Else
txtprice.Text = txtprice.Text - 300
End If
End Sub

Private Sub chkham_CheckedChange(Checked As Boolean)


If chkham.Checked = True Then
txtprice.Text = txtprice.Text + 200
Else
txtprice.Text = txtprice.Text - 200
End If
End Sub

Private Sub btnAccept_Click


Main.priceforpizza = txtprice.Text
Msgbox("Transaction Confirmed","Successful")
Activity.Finish
End Sub

Codes for Drinks Module

Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.

End Sub

Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.

Private chkcoffe As CheckBox


Private chktea As CheckBox
Private chksoda As CheckBox
Private txtprice2 As EditText
End Sub

JBQ@2021
College of Computing Studies

Sub Activity_Create(FirstTime As Boolean)


'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("laydrinks")

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Private Sub btnHome_Click


Activity.Finish
End Sub

Private Sub btnclear_Click


chkcoffe.Checked = False
chktea.Checked = False
chksoda.Checked = False
txtprice2.Text = 0
End Sub

Private Sub chkcoffe_CheckedChange(Checked As Boolean)


If chkcoffe.Checked = True Then
txtprice2.Text = txtprice2.Text + 50
Else
txtprice2.Text = txtprice2.Text - 50
End If
End Sub

Private Sub chktea_CheckedChange(Checked As Boolean)


If chktea.Checked = True Then
txtprice2.Text = txtprice2.Text + 40
Else
txtprice2.Text = txtprice2.Text - 40
End If
End Sub

Private Sub chksoda_CheckedChange(Checked As Boolean)


If chksoda.Checked = True Then
txtprice2.Text = txtprice2.Text + 30

JBQ@2021
College of Computing Studies

Else
txtprice2.Text = txtprice2.Text - 30
End If
End Sub

Private Sub btnaccept2_Click


Main.pricefordrinks = txtprice2.Text
Msgbox("Transaction Confirmed","Successful")
Activity.Finish
End Sub

Prepared by:

Joel B. Quiambao
Instructor 1

JBQ@2021

You might also like