Hi all,
I have problem my source code after ran my widget.
Please help me looking for the problem which is belows
Best Regards
Theera
I have problem my source code after ran my widget.
B4X:
Sub BtnSearch_click
'if Questions.get(i) is checked will shown Answer.get(i)
Dim i, row As Int
Dim lstQ, lstA As List
Dim Amt As Double
Amt = 0
lstQ.Initialize
lstA.Initialize
Log(CurrentPage)
lstQ = Questions.Get(CurrentPage)
lstA = Answers.Get(CurrentPage)
Log(lstQ.Size)
pnlAnswers.Visible = True
pnlAnswers.BringToFront
lblPlant.Text = Plants.Get(CurrentPage)
Dim pnl As Panel
pnl = container.GetPageObject(CurrentPage)
Dim scv As ScrollView
scv = pnl.GetView(0)
Log(scv.Panel.NumberOfViews)
Dim i As Int
Dim txt As String
txt = ""
' added Step 4 because you have 4 views per row
' so should check only every 4th view
For i = 0 To scv.Panel.NumberOfViews - 1 Step 4
row = i / 4
Dim chk As CheckBox
chk = scv.Panel.GetView(i)
If chk.Checked = True Then
If txt <> "" Then
txt = txt & CRLF & CRLF
End If
' answer in one line
' txt = txt & CRLF & CRLF & lstQ.Get(row) & CRLF & " " & lstA.Get(row)
' answers in x lines
txt = txt & lstQ.Get(row)
Dim str() As String
str = Regex.Split("\+", lstA.Get(row))
Dim j As Int
For j = 0 To str.Length - 1
txt = txt & CRLF & " " & str(j)
Next
Dim Val1, Val2, Total As Double
Total = 0
Dim edt As EditText
edt = scv.Panel.GetView(chk.Tag * 4 + 1) ' the view with index 1 is the EditText
Val2 = edt.Text
Dim z As Int
For z = 0 To str.Length-1
Dim TargerStr() As String
TargerStr = Regex.Split(" ", str(z))
If IsNumber(TargerStr(1)) = True Then
Val1 = TargerStr(1) ' checks if the number is in TargerStr(1)
Else
Val1 = TargerStr(2) ' or in TargerStr(2)
End If
Total =Total + (Val1 * Val2)
Next
txt = txt & CRLF & " "&"ซื้อจำนวน"&" "&edt.Text&" ชุด"
txt = txt & CRLF & " "&"ยอดเงิน:"&" "&NumberFormat(Total,0,2) &" บาท"
Amt = Amt + Total
End If
Next
AccuTxtAnswers=AccuTxtAnswers & CRLF & CRLF & txt
GrandTotal=GrandTotal+Amt
txt = txt & CRLF &"ยอดเงินรวม:"&" "&NumberFormat(Amt,0,2) &" บาท"
lblAnswers.Text = txt
Dim h As Int
h = stu.MeasureMultilineTextHeight(lblAnswers, txt)
lblAnswers.Height = h
scvAnswers.Panel.Height = h
DoEvents
End Sub
Please help me looking for the problem which is belows
Best Regards
Theera
Last edited: