Hi team,
If you want to load the data in to B4x table, You just make the data as List.
but here, I wanna load one string value in to B4x table.
How to do it? I tried but no success
Here is the code.
B4X:
Sub ic_customcamera_result_found(result As String)
Dim root As List
root.Initialize
For Each colroot As Map In root
barcode_result = colroot.Get(result)
root.Add(barcode_result)
Next
B4xtable.SetData(root)
End If
End Sub
Thanks for your suggestion sir,
I found result. Here
B4X:
Dim root As List
root.Initialize
Dim row(1) As Object
row(0) = result
root.Add(row)
printDataTable.SetData(root)
But Have one Doubt sir,
How do I write in Loop sir, This is little confusion for me.
I tried with resultset but I don't want any data fetch from database. so How to use while loop to go print next value on next row sir.
Here is sample code.
B4X:
Dim root As List
root.Initialize
Do While (how to go with next row)
Dim row(1) As Object
row(0) = result
root.Add(row)
Loop
printDataTable.SetData(root)
If your data is coming from a list, you can do this:
B4X:
Dim MyList As List
MyList.Initialize
MyList = Array ("Apple", "Banana", "Cherry", "Coconut", "Grapes", "Lemon", "Mango", "Melon")
Dim data As List
data.Initialize
For Each s As String In MyList
Dim r(1) As String
r(0)=s
data.Add(r)
Next
B4XTable1.SetData(data)
'or this:
For i=0 To MyList.Size-1
Dim r(1) As String
r(0)=MyList.Get(i)
data.Add(r)
Next
B4XTable1.SetData(data)
Do you have to excessively use the word 'sir' in your post.
If your data is coming from a list, you can do this:
B4X:
Dim MyList As List
MyList.Initialize
MyList = Array ("Apple", "Banana", "Cherry", "Coconut", "Grapes", "Lemon", "Mango", "Melon")
Dim data As List
data.Initialize
For Each s As String In MyList
Dim r(1) As String
r(0)=s
data.Add(r)
Next
B4XTable1.SetData(data)
'or this:
For i=0 To MyList.Size-1
Dim r(1) As String
r(0)=MyList.Get(i)
data.Add(r)
Next
B4XTable1.SetData(data)
Do you have to excessively use the word 'sir' in your post.
Thanks for your suggestion.
But I didn't load the data from the list. My concept is Scan the one barcode and It will appear on the table.
Problem is I can add the only one data.
For example, First I go to scan the one barcode and it will successfully add the table. and Again I go to scan the another one barcode that will also
appear in the table. But First barcode number is deleted. I mean second barcode number replace the first barcode number.
But I want to print the second barcode on second row, then If I go to scan the third barcode, and it will appear on the 3rd Barcode. No data will be replaced.
Here is the sample code:
B4X:
Private ic_customcamera As QRCodeReaderView
Sub btn_resultbarcode_Click
' ilbl_resultfirst.Text = ""
ip_camerabarcodescannerpanel.Visible = True
Panel1.Visible = False
ic_customcamera.Visible = True
ic_customcamera.startScan
End Sub
Sub ic_customcamera_result_found(result As String)
ilbl_resultfirst.Text = result
If ilbl_resultfirst.Text <> "" Then
ic_customcamera.stopScan
ic_customcamera.Visible = False
ip_camerabarcodescannerpanel.Visible = False
Panel1.Visible = True
Dim root As List
root.Initialize
Dim row(1) As Object
row(0) = result
root.Add(row)
B4xTable.SetData(root)
End Sub
To display the scanned barcode in the in-memory table and B4XTable, you can do this every time you scan a barcode. But once you exit the app, you will lose that new data , unless you make sure to save it to a list or SQLite database in the device so next time you enter your app., the data you entered earlier appears.
B4X:
Sub ic_customcamera_result_found(result As String)
ilbl_resultfirst.Text = result
If ilbl_resultfirst.Text <> "" Then
ic_customcamera.stopScan
ic_customcamera.Visible = False
ip_camerabarcodescannerpanel.Visible = False
Panel1.Visible = True
Dim row(1) As Object
row(0) = result
B4XTable.sql1.ExecNonQuery2($"INSERT INTO data VALUES( ?)"$, row)
B4XTable.ClearDataView
End If
End Sub
To display the scanned barcode in the in-memory table and B4XTable, you can do this every time you scan a barcode. But once you exit the app, you will lose that new data , unless you make sure to save it to a list or SQLite database in the device so next time you enter your app., the data you entered earlier appears.
B4X:
Sub ic_customcamera_result_found(result As String)
ilbl_resultfirst.Text = result
If ilbl_resultfirst.Text <> "" Then
ic_customcamera.stopScan
ic_customcamera.Visible = False
ip_camerabarcodescannerpanel.Visible = False
Panel1.Visible = True
Dim row(1) As Object
row(0) = result
B4XTable.sql1.ExecNonQuery2($"INSERT INTO data VALUES( ?)"$, row)
B4XTable.ClearDataView
End If
End Sub
Thanks for your suggestion.
But My problem is different.
Using B4X table. If I scan one barcode, the barcode value correctly appear in the first row in B4X Table. Thats fine.
And Again I go to scan the another one barcode, the second value should appear in second row. But Second value replace the first value and
appear in the first row.
I just want, How many barcode I scan all the values appear in the correct row, I mean 1st scan barcode in the first row, 2nd scan barcode in the second row, 3rd ...... thats like.
First of all without saving the data in list or sqlite this above concept is possible or not?
The code I gave you saves the scanned text to the next row available to the memory database and shows it in the B4XTable in the order you scanned them. If the table has no rows to begin with, then, the barcode shows up in the first row and so on. If the table already has data, the scanned barcode shows up at the end of the table immediately. If your current project replaces the first scanned barcode with the second and you lose the first one, then, something you are doing is making it replace the first with the second.
If you want to create a small project substituting the barcode part with manual text, without using barcodes since I have not used that barcode library, I or someone else will look at it and try to help. If that is not possible, then export your project as is.