Android Question Global Variables problem

Lyndon Bermoy

Active Member
Licensed User
Longtime User
Can somebody help me how to fix this? I want display the text value on the other module but there is no display. Here is the code:

- BJavaBooks.bas
B4X:
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
  Dim sql1 As SQL
   Dim cursor1 As Cursor
  
   Dim x1,x2,x3 As String
  
End Sub

Sub ListView1_ItemClick (Position As Int, Value As Object)

Dim idvalue As String
Dim countIt As Int
Dim ID As String
idvalue = Value
'countIt = idvalue.IndexOf("-") 'find location of sperator
'idvalue = idvalue.SubString2(0,countIt) 'find first part of label text
ID = idvalue
cursor1 = sql1.ExecQuery("SELECT * FROM main where ID = '" & ID & "' ")
For i = 0 To cursor1.RowCount - 1
cursor1.Position = i
   x1 =cursor1.getString("BType")
   x2=cursor1.getString("BTitle")
   x3=cursor1.getString("BAuthor")
   StartActivity("BTitles")
Next


End Sub
-BTitles.bas
B4X:
Sub Activity_Create(FirstTime As Boolean)

   Activity.LoadLayout("bookstitle")
  TTS.InitializeTTs("tts", "English")
    If File.Exists(File.DirInternal,"Books1.db") = False Then
     File.Copy(File.DirAssets,"Books1.db",File.DirInternal,"Books1.db")
   End If
  
  
   If sql1.IsInitialized = False Then
     sql1.Initialize(File.DirInternal, "Books1.db", False)
   End If
  
   lblType.Text = BJavaBooks.x1
   lblTitle.Text = BJavaBooks.x2
   lblAuthor.Text = BJavaBooks.x3
End Sub
If I will click the listview, the data on the global variables will be passed on the labels of BTitles.bas. How can I make it? thanks
 
Last edited:

mangojack

Well-Known Member
Licensed User
Longtime User
please use [code]Insert your code here ..[/code] tags when posting code..

change
B4X:
Dim x1,x2,x3 As String

to ..
B4X:
Public x1,x2,x3 As String
 
Upvote 0

Lyndon Bermoy

Active Member
Licensed User
Longtime User
please use [code]Insert your code here ..[/code] tags when posting code..

change
B4X:
Dim x1,x2,x3 As String

to ..
B4X:
Public x1,x2,x3 As String

When i changed to that it gives me error that
B4X:
BJavaBooks.x1
. Can't access to x1 when i use the dot noitation of BJavaBooks
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
can u post error message ?
 
Upvote 0
Top