I have a code below that is working only for one instance. It only allows one time call and then throw b4xview uninitialized error when trying to call it more than one. I tried tracing the uninitialized b4xview but to no success. Here is the code sub and how it was called:
Now, i tried calling the sub multiple times into pnl1, pnl2,.... thus:
b4xtable(Pnl1,4,0,"tbl1x","5")
b4xtable(Pnl2, 2, 1,"tbl2x","7")
...... ........
...... .......
Calling only works at one instance, but fails at multiple calls. Please help me with correct resumable or help me with another code that can achieve same result multiple times. The layout ("B4XT") is just empty b4xtable in the designer
B4X:
Private Sub b4xtable(pnl As B4XView ,maxrow As Int,tag As Object,tblnameb As String,tblcountb As String) 'As ResumableSub 'As B4XTable
'Use: b4xtable(98%x, 300dip, Pnl2)
'pnl.SetLayoutAnimated(0, 0, 0, Width, Height)
pnl.LoadLayout("B4XT")
Dim tblname As String = tblnameb '"tbl1x"
Dim tblcount As String = tblcountb '"5"
B4XTable1.mBase.Tag = "B4XTableb" & tag
Sleep(0)
B4XTable1.pnlHeader.Visible = False
B4XTable1.RowHeight = 40dip '30dip
B4XTable1.HeadersHeight = 40dip '30dip
B4XTable1.MaximumRowsPerPage = maxrow '4 'make it variable name
B4XTable1.BuildLayoutsCache(maxrow) '4
B4XTable1.mBase.Top = -58dip '-60 'to move table to top to cover empty rows
Try
'
If (tblcount = "5" ) Then
B4XTable1.AddColumn("id", B4XTable1.COLUMN_TYPE_NUMBERS)
B4XTable1.AddColumn("t1", B4XTable1.COLUMN_TYPE_TEXT)
B4XTable1.AddColumn("t2", B4XTable1.COLUMN_TYPE_TEXT)
B4XTable1.AddColumn("t3", B4XTable1.COLUMN_TYPE_TEXT)
B4XTable1.AddColumn("t4", B4XTable1.COLUMN_TYPE_TEXT)
B4XTable1.AddColumn("t5", B4XTable1.COLUMN_TYPE_TEXT)
End If
'
If (tblcount = "6" ) Then
B4XTable1.AddColumn("id", B4XTable1.COLUMN_TYPE_NUMBERS)
B4XTable1.AddColumn("t1", B4XTable1.COLUMN_TYPE_TEXT)
B4XTable1.AddColumn("t2", B4XTable1.COLUMN_TYPE_TEXT)
B4XTable1.AddColumn("t3", B4XTable1.COLUMN_TYPE_TEXT)
B4XTable1.AddColumn("t4", B4XTable1.COLUMN_TYPE_TEXT)
B4XTable1.AddColumn("t5", B4XTable1.COLUMN_TYPE_TEXT)
B4XTable1.AddColumn("t6", B4XTable1.COLUMN_TYPE_TEXT)
End If
If (tblcount = "7" ) Then
B4XTable1.AddColumn("id", B4XTable1.COLUMN_TYPE_NUMBERS)
B4XTable1.AddColumn("t1", B4XTable1.COLUMN_TYPE_TEXT)
B4XTable1.AddColumn("t2", B4XTable1.COLUMN_TYPE_TEXT)
B4XTable1.AddColumn("t3", B4XTable1.COLUMN_TYPE_TEXT)
B4XTable1.AddColumn("t4", B4XTable1.COLUMN_TYPE_TEXT)
B4XTable1.AddColumn("t5", B4XTable1.COLUMN_TYPE_TEXT)
B4XTable1.AddColumn("t6", B4XTable1.COLUMN_TYPE_TEXT)
B4XTable1.AddColumn("t7", B4XTable1.COLUMN_TYPE_TEXT)
End If
Dim Data As List
Data.Initialize
If (tblcount = "5") Then
Dim res As ResultSet = B4XPages.MainPage.SQL1.ExecQuery($"SELECT id,tablenamearray,tablecount,t1,t2,t3,t4,t5 FROM alltable WHERE tablenamearray ='${tblname}' and tablecount ='${tblcount}'"$)
End If
If (tblcount = "6") Then
Dim res As ResultSet = B4XPages.MainPage.SQL1.ExecQuery($"SELECT id,tablenamearray,tablecount,t1,t2,t3,t4,t5,t6 FROM alltable WHERE tablenamearray ='${tblname}' and tablecount ='${tblcount}'"$)
End If
If (tblcount = "7") Then
Dim res As ResultSet = B4XPages.MainPage.SQL1.ExecQuery($"SELECT id,tablenamearray,tablecount,t1,t2,t3,t4,t5,t6,t7 FROM alltable WHERE tablenamearray ='${tblname}' and tablecount ='${tblcount}'"$)
End If
Do While res.NextRow
Dim tablecount As String = res.GetString(res.GetColumnName(2))
If (tablecount = "5") Then '8-3 'And res.GetColumnName(6) <> ""
Dim row(6) As String 'Object res.ColumnCount
row(0) = res.GetInt(res.GetColumnName(0))'id
row(1) = res.GetString(res.GetColumnName(3))'tablename
row(2) = res.GetString(res.GetColumnName(4))'tablecount
row(3) = res.GetString(res.GetColumnName(5))
row(4) = res.GetString(res.GetColumnName(6))
row(5) = res.GetString(res.GetColumnName(7))
End If
If (tablecount = "6" ) Then '8-3 'And res.GetColumnName(6) <> ""
Dim row(7) As String 'Object res.ColumnCount
row(0) = res.GetInt(res.GetColumnName(0))'id
row(1) = res.GetString(res.GetColumnName(3))'tablename
row(2) = res.GetString(res.GetColumnName(4))'tablecount
row(3) = res.GetString(res.GetColumnName(5))
row(4) = res.GetString(res.GetColumnName(6))
row(5) = res.GetString(res.GetColumnName(7))
row(6) = res.GetString(res.GetColumnName(8))
End If
If (tablecount = "7" ) Then '8-3 ' And res.GetColumnName(j) <> Null
Dim row(8) As String 'Object res.ColumnCount
row(0) = res.GetInt(res.GetColumnName(0))'id
row(1) = res.GetString(res.GetColumnName(3))'tablename
row(2) = res.GetString(res.GetColumnName(4))'tablecount
row(3) = res.GetString(res.GetColumnName(5))
row(4) = res.GetString(res.GetColumnName(6))
row(5) = res.GetString(res.GetColumnName(7))
row(6) = res.GetString(res.GetColumnName(8))
row(7) = res.GetString(res.GetColumnName(9))
End If
Loop
B4XTable1.SetData(Data)
Catch
Log("Error=" & LastException.Message)
End Try
End Sub
Now, i tried calling the sub multiple times into pnl1, pnl2,.... thus:
b4xtable(Pnl1,4,0,"tbl1x","5")
b4xtable(Pnl2, 2, 1,"tbl2x","7")
...... ........
...... .......
Calling only works at one instance, but fails at multiple calls. Please help me with correct resumable or help me with another code that can achieve same result multiple times. The layout ("B4XT") is just empty b4xtable in the designer
Last edited: