dexlicious19
Member
#Region Project Attributes
#ApplicationLabel: MySecondProgram
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: True
#IncludeTitle: False
#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 btnAction, btn0 As Button
Private lblResult As Label
Private lblComments As Label
Private lblMathSign As Label
Private lblNumber1 As Label
Private lblNumber2 As Label
Public Number1, Number2 As Int
End Sub
Sub btnEvent_Click
Private btnSender As Button
btnSender = Sender
Select btnSender.Tag
Case "BS"
If lblResult.Text.Length >0 Then
lblResult.Text = lblResult.Text.SubString2(0, lblResult.Text.Length - 1)
End If
Case Else
lblResult.Text = lblResult.Text & btnSender.Tag
End Select
If lblResult.Text.Length = 0 Then
btn0.Visible = False
Else
btn0.Visible = True
End If
End Sub
Sub NewProblem
Number1 = Rnd(1,10)
Number2 = Rnd(1,10)
lblNumber1.Text = Number1
lblNumber2.Text = Number2
lblComments.Text = "Enter the result" & CRLF & "and click on OK"
lblComments.Color = Colors.RGB(255,235,128)
lblResult.Text = ""
btn0.Visible = False
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Main")
NewProblem
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub btnAction_Click
If btnAction.Text = "O K" Then
If lblResult.Text = " " Then
Msgbox("No result entered","E R R OR")
Else
CheckResult
End If
Else
NewProblem
btnAction.Text = "O K"
End If
End Sub
Sub CheckResult
If lblResult.Text = Number1 + Number2 Then
lblComments.Text = "G O O D result" & CRLF & "Click on NEW"
lblComments.Color = Colors.RGB(128,255,128)
btnAction.Text = "N E W"
Else
lblComments.Text = "W R O N G" & CRLF & "Enter a new result" & CRLF & "and click OK"
lblComments.Color = Colors.RGB(255,128,128)
End If
End Sub
#ApplicationLabel: MySecondProgram
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: True
#IncludeTitle: False
#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 btnAction, btn0 As Button
Private lblResult As Label
Private lblComments As Label
Private lblMathSign As Label
Private lblNumber1 As Label
Private lblNumber2 As Label
Public Number1, Number2 As Int
End Sub
Sub btnEvent_Click
Private btnSender As Button
btnSender = Sender
Select btnSender.Tag
Case "BS"
If lblResult.Text.Length >0 Then
lblResult.Text = lblResult.Text.SubString2(0, lblResult.Text.Length - 1)
End If
Case Else
lblResult.Text = lblResult.Text & btnSender.Tag
End Select
If lblResult.Text.Length = 0 Then
btn0.Visible = False
Else
btn0.Visible = True
End If
End Sub
Sub NewProblem
Number1 = Rnd(1,10)
Number2 = Rnd(1,10)
lblNumber1.Text = Number1
lblNumber2.Text = Number2
lblComments.Text = "Enter the result" & CRLF & "and click on OK"
lblComments.Color = Colors.RGB(255,235,128)
lblResult.Text = ""
btn0.Visible = False
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Main")
NewProblem
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub btnAction_Click
If btnAction.Text = "O K" Then
If lblResult.Text = " " Then
Msgbox("No result entered","E R R OR")
Else
CheckResult
End If
Else
NewProblem
btnAction.Text = "O K"
End If
End Sub
Sub CheckResult
If lblResult.Text = Number1 + Number2 Then
lblComments.Text = "G O O D result" & CRLF & "Click on NEW"
lblComments.Color = Colors.RGB(128,255,128)
btnAction.Text = "N E W"
Else
lblComments.Text = "W R O N G" & CRLF & "Enter a new result" & CRLF & "and click OK"
lblComments.Color = Colors.RGB(255,128,128)
End If
End Sub