gpt4 book ai didi

mysql - 如何在同一行的datagridview中插入2个不同的数组字符串

转载 作者:行者123 更新时间:2023-11-29 22:44:00 26 4
gpt4 key购买 nike

我有一个带有 Richtextbox 的 win 表单,在我给出一些命令(例如(AT+DSCA 和 AT+RSSI))后,它会从串行 COM 端口读取这两个命令被依次执行收到的字符串如下:对于 at+dscan ,字符串如下: ZC* |0001950000008F8B|0000|PTv1.11|ZE20S|ProBee-ZE 我有以下 vb.net 代码来分割此字符串并将其插入到 datagridview 中:前 2 个值。

Private Sub SalveazaData()
Dim Rows As String() = rtbComData.Text.Split(Environment.NewLine.ToCharArray())
For Each Row As String In Rows
If Not (Row = "AT+DSCAN" Or Row = "OK" Or Row = "") Then
Dim sAry As String() = Split(Row, "|")
Dim aRow As smdDataDataSet1.smdTableRow = SmdDataDataSet1.smdTable.NewsmdTableRow()
aRow.Model = sAry(0)
aRow.AdresaUnica = sAry(1)
aRow.StatusModul = "ACTIVE"
Try
SmdDataDataSet1.SearchAdrese.Rows.Add(sAry(1))
SmdDataDataSet1.smdTable.Rows.Add(aRow)
Catch ex As Exception
Dim u As String
u = SmdTableTableAdapter.UpdateInactivActiv()
End Try
End If

Next

对于第二个命令 AT+RSSI,其字符串如下:Sender: 0000, Parent: FFFF, RSSI: 0, LQI: 255 无法将值 255 插入与前一个字符串相同的行!我只想在与上述字符串相同的行上插入值-“255”

最佳答案

我了解您的需求,解析来自 COM 端口的值并使用这些值在 datagridview 中显示。//找出哪个索引有这么长的字符串值

//“ProBee-ZE 发件人:0000,父级:FFFF,RSSI:0,LQI:255 发件人:0000,”

//例如我们有 sAry(3)。

 Dim tAry As String() = Split(sAry(3), ",")

//tAry(3)中得到LQI: 255,同样的过程得到255

 Dim uAry As String() = Split(tAry(3), ":")

//您将得到值为 255 的 uAry(1)//您需要将此代码放入 for 循环中。

 For Each Row As String In Rows
If Not (Row = "AT+DSCAN" Or Row = "OK" Or Row = "") Then

Dim sAry As String() = Split(Row, "|")
Dim aRow As smdDataDataSet1.smdTableRow = SmdDataDataSet1.smdTable.NewsmdTableRow()
aRow.Model = sAry(0)
aRow.AdresaUnica = sAry(1)
aRow.StatusModul = "ACTIVE"
aRow.thecolumnwhichuwant = uAry(1)


Try
SmdDataDataSet1.SearchAdrese.Rows.Add(sAry(1))
SmdDataDataSet1.smdTable.Rows.Add(aRow)
Catch ex As Exception
Dim u As String
u = SmdTableTableAdapter.UpdateInactivActiv()
End Try
End If

Next

关于mysql - 如何在同一行的datagridview中插入2个不同的数组字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29210003/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com