【问题标题】:How to solve "object converted to string" error in B4A如何解决 B4A 中的“对象转换为字符串”错误
【发布时间】:2021-03-09 08:49:31
【问题描述】:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Type DBResult (Tag As Object, **Columns As Map**, Rows As List)
Type DBCommand (Name As String, Parameters() As Object)
Private const rdcLink As String = "http://192.168.8.100:17178/rdc"
End Sub

这是进程全局变量的方法。这里 columns As Map 被初始化。 然而,下面代码中加粗的行给出了一个错误,“对象转换为字符串。这可能是一个编程错误。(警告 #7)”

Sub GetRecord
Dim req As DBRequestManager = CreateRequest
Dim cmd As DBCommand = CreateCommand("selectAllNames", Null)
Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)
If j.Success Then
    req.HandleJobAsync(j, "req")
    Wait For (req) req_Result(res As DBResult)
    'work with result
    'req.PrintTable(res)
    ***Log(res.Columns)***
    ListViewListTable.Clear
    For Each row() As Object In res.Rows
        Dim oBitMap As Bitmap
        Dim buffer() As Byte
        buffer = row(res.Columns.Get("gambar"))
        oBitMap = req.BytesToImage(buffer)
        ListViewListTable.AddTwoLinesAndBitmap(row(1), "See more...", oBitMap)
    Next
Else
    Log("ERROR: " & j.ErrorMessage)
End If
j.Release
End Sub

那么我应该怎么做才能消除错误呢?

【问题讨论】:

  • 是不是 res.columns 某种集合或地图?它不能转换为字符串,它看起来是某种类型的集合或列表。

标签: vb4android


【解决方案1】:

如果列是地图? (看起来是什么?)。

然后要显示列,您可以使用:

For Each MyKey As String in res.Columns.Keys
   log("Key name = " & MyKey)
   log("Key value = " & res.Columns.Get(MyKey))
Next

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-06-09
    • 2011-06-24
    • 2021-11-09
    • 1970-01-01
    • 2020-10-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多