Android Question Why does CallSub always cause app crashes?

bskotu555

Member
B4X:
Private Sub EditText1_EnterPressed'获取聊天记录
    If EditText1.Text=""  Then
        MsgboxAsync("请先输入ID再操作","提示")
    Else
        CallSub(RE,"RE")
        EditText2.RequestFocus
    End If
End Sub

Sub RE
    Dim Cursor As JdbcResultSet
    Dim cxx As String =EditText1.text'ID
    CustomListView1.Clear
    Cursor = Starter.Mysql_Jdbc.ExecQuery2("SELECT * FROM chat WHERE `ChatID`=? ", Array As String(cxx)) '防止SQL注入
    Do While Cursor.NextRow
        CustomListView1.AddTextItem(Cursor.GetString("Nickname") & " " & Cursor.GetString("time") & Chr(10) & Cursor.GetString("Text"), "")
    Loop
End Sub
 

jkhazraji

Active Member
Licensed User
Longtime User
B4X:
Private Sub EditText1_EnterPressed'获取聊天记录
    If EditText1.Text=""  Then
        MsgboxAsync("请先输入ID再操作","提示")
    Else
        CallSub(RE,"RE")
        EditText2.RequestFocus
    End If
End Sub

Sub RE
    Dim Cursor As JdbcResultSet
    Dim cxx As String =EditText1.text'ID
    CustomListView1.Clear
    Cursor = Starter.Mysql_Jdbc.ExecQuery2("SELECT * FROM chat WHERE `ChatID`=? ", Array As String(cxx)) '防止SQL注入
    Do While Cursor.NextRow
        CustomListView1.AddTextItem(Cursor.GetString("Nickname") & " " & Cursor.GetString("time") & Chr(10) & Cursor.GetString("Text"), "")
    Loop
End Sub
The syntax is : CallSub(Main, "RE")
or Consider using CallSubDelayed
 
Upvote 0

jkhazraji

Active Member
Licensed User
Longtime User
Whether it is in the same module or in the main is not mentioned and it seems to be in the main because of the use of a UI (EditText1_EnterPressed)
I thought there is a goal of using CallSub.
Just use RE alone
 
Upvote 0
Top