How to use CallSub function

Hey there! Have just beginned with B4A and I am trying to code a quiz game but the CallSub function didn't worked or I do not know how to use it my code looks like this:

B4X:
#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: 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.
   
   Dim CheckBox1 As CheckBox
   Dim CheckBox2 As CheckBox

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("Layout1")
   Msgbox("Welcome to Kevin's First application!", "Kevin's Application")
   Activity.LoadLayout("Layout1")
      
End Sub
Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)


End Sub


Sub Button1_Click
    
   If CheckBox1.Checked = True Then
   CheckBox1.Checked = False 
   Else
   CheckBox1.Checked = True
   Msgbox("The quiz has begun!", "Started Quiz")
              CallSub(Module1, "GoToNextWindow")
   End If
   
   If CheckBox2.Checked = True Then
   CheckBox2.Checked = False
   End If
   
   CallSub(Module1, "RefreshData")
   
End Sub
Sub Button2_Click

   If CheckBox2.Checked = True Then
   CheckBox2.Checked = False
   Else
   CheckBox2.Checked = True
   Msgbox("You where not ready to start quiz", "User Not Ready")
   End If
   
   If CheckBox1.Checked = True Then
   CheckBox1.Checked = False
   End If
:sign0085:
 

Tom Christman

Active Member
Licensed User
Longtime User
Klaus has composed the Beginners Guide pdf available from the B4A website. Download the pdf and go to page 218 to answer your questions. It's a great tool for all users!
 
Upvote 0
Top