0% found this document useful (0 votes)
19 views5 pages

ALL Visual Basic Code

The document contains code for a mobile application that calculates meal and drink totals, applies discounts, and transitions between activities. It includes attributes, global variables, and event handler code to manage UI elements and perform calculations.

Uploaded by

2022307897
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views5 pages

ALL Visual Basic Code

The document contains code for a mobile application that calculates meal and drink totals, applies discounts, and transitions between activities. It includes attributes, global variables, and event handler code to manage UI elements and perform calculations.

Uploaded by

2022307897
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

(MAIN)

#Region Project Attributes


#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region

#Region Activity Attributes


#FullScreen: False
#IncludeTitle: True
#End Region

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 mealsprice As String
Dim drinksprice As String
End Sub

Sub Globals
'These global variables will be redeclared each time the activity is created.
Private btnMeals As Button
Private btnDrinks As Button
Private btnTotal As Button
Private btnClear As Button
Private btnExit As Button
Private txtMeals As EditText
Private txtDrinks As EditText
Private txtTottal As EditText
Private rb20 As RadioButton
Private rb10 As RadioButton
Private rb5 As RadioButton
Private rb0 As RadioButton
Private txtdiscount As EditText
Private txtDprice As EditText
End Sub

Sub Activity_Create(FirstTime As Boolean)


Activity.LoadLayout("Layout")
End Sub

Sub Activity_Resume
txtMeals.Text = mealsprice
txtDrinks.Text = drinksprice
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Button1_Click
xui.MsgboxAsync("Hello world!", "B4X")
End Sub

Private Sub btnMeals_Click


StartActivity(meals)
End Sub

Private Sub btnDrinks_Click


StartActivity(drinks)
End Sub

Private Sub btnTotal_Click


txtTottal.Text = txtMeals.Text + txtDrinks.text
End Sub

Private Sub rb0_CheckedChange(Checked As Boolean)


txtdiscount.Text = txtTottal.Text * 0
txtDprice.Text = txtTottal.Text - txtdiscount.text
End Sub

Private Sub rb5_CheckedChange(Checked As Boolean)


txtdiscount.Text = txtTottal.Text * .05
txtDprice.Text = txtTottal.Text - txtdiscount.text
End Sub

Private Sub rb10_CheckedChange(Checked As Boolean)


txtdiscount.Text = txtTottal.Text * .1
txtDprice.Text = txtTottal.Text - txtdiscount.text
End Sub

Private Sub rb20_CheckedChange(Checked As Boolean)


txtdiscount.Text = txtTottal.Text * .2
txtDprice.Text = txtTottal.Text - txtdiscount.text
End Sub

Private Sub btnExit_Click


ExitApplication
End Sub

Private Sub btnClear_Click


txtMeals.Text = ""
txtDrinks.Text = ""
txtTottal.Text = ""
txtdiscount.Text = ""
txtDprice.Text = ""
End Sub

(MEALS)

#Region Project Attributes


#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region

#Region Activity Attributes


#FullScreen: False
#IncludeTitle: True
#End Region
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 mealsprice As String
Dim drinksprice As String
End Sub

Sub Globals
'These global variables will be redeclared each time the activity is created.
Private btnMeals As Button
Private btnDrinks As Button
Private btnTotal As Button
Private btnClear As Button
Private btnExit As Button
Private txtMeals As EditText
Private txtDrinks As EditText
Private txtTottal As EditText
Private rb20 As RadioButton
Private rb10 As RadioButton
Private rb5 As RadioButton
Private rb0 As RadioButton
Private txtdiscount As EditText
Private txtDprice As EditText
End Sub

Sub Activity_Create(FirstTime As Boolean)


Activity.LoadLayout("Layout")
End Sub

Sub Activity_Resume
txtMeals.Text = mealsprice
txtDrinks.Text = drinksprice
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Button1_Click
xui.MsgboxAsync("Hello world!", "B4X")
End Sub

Private Sub btnMeals_Click


StartActivity(meals)
End Sub

Private Sub btnDrinks_Click


StartActivity(drinks)
End Sub

Private Sub btnTotal_Click


txtTottal.Text = txtMeals.Text + txtDrinks.text
End Sub

Private Sub rb0_CheckedChange(Checked As Boolean)


txtdiscount.Text = txtTottal.Text * 0
txtDprice.Text = txtTottal.Text - txtdiscount.text
End Sub
Private Sub rb5_CheckedChange(Checked As Boolean)
txtdiscount.Text = txtTottal.Text * .05
txtDprice.Text = txtTottal.Text - txtdiscount.text
End Sub

Private Sub rb10_CheckedChange(Checked As Boolean)


txtdiscount.Text = txtTottal.Text * .1
txtDprice.Text = txtTottal.Text - txtdiscount.text
End Sub

Private Sub rb20_CheckedChange(Checked As Boolean)


txtdiscount.Text = txtTottal.Text * .2
txtDprice.Text = txtTottal.Text - txtdiscount.text
End Sub

Private Sub btnExit_Click


ExitApplication
End Sub

Private Sub btnClear_Click


txtMeals.Text = ""
txtDrinks.Text = ""
txtTottal.Text = ""
txtdiscount.Text = ""
txtDprice.Text = ""
End Sub

(DRINKS)
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region

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 cbSoda As CheckBox


Private cbCoffee As CheckBox
Private cbTea As CheckBox
Private btnAccept As Button
Private btnClear As Button
Private lbldrinks As Label
Private txtTDrinks 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("drinks_layout")

End Sub
Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Private Sub cbTea_CheckedChange(Checked As Boolean)


If cbTea.Checked = True Then
txtTDrinks.Text = txtTDrinks.text + 50
Else
txtTDrinks.Text = txtTDrinks.text-50
End If
End Sub

Private Sub cbCoffee_CheckedChange(Checked As Boolean)


If cbCoffee.Checked = True Then
txtTDrinks.Text = txtTDrinks.text + 70
Else
txtTDrinks.Text = txtTDrinks.text-70
End If
End Sub

Private Sub cbSoda_CheckedChange(Checked As Boolean)


If cbSoda.Checked = True Then
txtTDrinks.Text = txtTDrinks.Text + 45
Else
txtTDrinks.Text = txtTDrinks.Text-45
End If
End Sub

Private Sub btnAccept_Click


Main.drinksprice= txtTDrinks.Text
MsgboxAsync("transaction confirmed", "Successful")
Activity.finish
End Sub

Private Sub btnClear_Click


cbTea.Checked = False
cbSoda.Checked= False
cbCoffee.Checked = False
txtTDrinks.Text = 0
End Sub

You might also like