首页 > 代码库 > 学起来很简单!MyFirst_B4A_Program
学起来很简单!MyFirst_B4A_Program
#Region Project Attributes #ApplicationLabel: MyFirstProgram #VersionCode: 1 #VersionName: ‘SupportedOrientations possible values: unspecified, landscape or portrait. #SupportedOrientations: unspecified #CanInstallToExternalStorage: False #End Region#Region Activity Attributes #FullScreen: False #IncludeTitle: True#End RegionSub Process_Globals ‘These global variables will be declared once when the application starts. ‘These variables can be accessed from all modules.End SubSub Globals ‘These global variables will be redeclared each time the activity is created. ‘These variables can only be accessed from this module. Dim btnAction As Button Dim edtResult As EditText Dim lblComments As Label Dim lblMathSign As Label Dim lblNumber1 As Label Dim lblNumber2 As Label Dim Number1, Number2 As IntEnd SubSub Activity_Create(FirstTime As Boolean) ‘Do not forget to load the layout file created with the visual designer. For example: ‘Activity.LoadLayout("Layout1") Activity.LoadLayout("Main") New End SubSub Activity_ResumeEnd SubSub Activity_Pause (UserClosed As Boolean)End SubSub New Number1 = Rnd(1, 10) ‘ Generates a random number between 1 and 9 Number2 = Rnd(1, 10) ‘ Generates a random number between 1 and 9 lblNumber1.Text = Number1 ‘ Displays Number1 in label lblNumber1 lblNumber2.Text = Number2 ‘ Displays Number2 in label lblNumber2 lblComments.Text = "Enter the result" & CRLF & "and click on OK" edtResult.Text = "" ‘ Sets edtResult.Text to emptyEnd SubSub btnAction_Click If btnAction.Text = "O K" Then If edtResult.Text="" Then Msgbox("No result entered","E R R O R") Else CheckResult End If Else New btnAction.Text = "O K" End IfEnd SubSub CheckResult If edtResult.Text = Number1 + Number2 Then lblComments.Text = "G O O D result" & CRLF & "Click on NEW" btnAction.Text = "N E W" Else lblComments.Text = "W R O N G result" & CRLF & "Enter a new result" & CRLF & "and click OK" End IfEnd Sub
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。