[.NET] 這是VB的BUG嗎?(已解決)
請輸入專案類型(網站專案或者應用程式專案):VB2008應用程式專案
Struct.vb模組是宣告資料型態
Execute.vb模組是放解封包的程式碼
form1.vb是我的表單
我把檔案的資料結構都存進Device.Profile的ArrayList裡,
存了十筆資料後發現每一筆都是最後一筆(到中斷點十筆資料都還正確),
從其他地方又存了另外十筆資料進來,結果變成兩組最後一筆資料。
請問這種要怎麼解?
----Struct.vb-------------------------------------------------------
Structure CmdTable
Dim MainCmd, SubCmd, Data() As Byte
Dim DataCount As Integer
End Structure
Structure ProfileName
Dim profileName() As Byte '[16];
End Structure
Structure Device_str
Dim Profile As ArrayList
End Structure
Public Device As New Device_str
----ExecuteCmd.vb---------------------------------------------------
Public Function replyReadProfileName(ByVal cmd As CmdTable)
If cmd.DataCount = 16 Then
'....
ElseIf (cmd.DataCount Mod 16 = 0) Then
Device.Profile.Clear()
Dim Profile As New ProfileName
Dim b(16) As Byte
Dim deb As New ArrayList
For i = 0 To (cmd.DataCount / 16) - 1
For j = 0 To 16 - 1
b(j) = cmd.Data(i * 16 + j)
Next
Profile.profileName = b
Device.Profile.Add(Profile) '中斷點
ReDim b(16) '就是這行解決!!
Next
End If
Return 0
End Function
----Form1.vb-------------------------------------------------------
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Device.Profile = New ArrayList
Dim cmd As New CmdTable
Dim d() As Byte = { _
74, 65, 73, 74, 5F, 70, 63, 30, 20, 20, 20, 20, 20, 20, 20, 0 _
, 74, 65, 73, 74, 5F, 70, 63, 31, 20, 20, 20, 20, 20, 20, 20, 0 _
, 74, 65, 73, 74, 5F, 70, 63, 32, 20, 20, 20, 20, 20, 20, 20, 0 _
, 74, 65, 73, 74, 5F, 70, 63, 33, 20, 20, 20, 20, 20, 20, 20, 0 _
, 74, 65, 73, 74, 5F, 70, 63, 34, 20, 20, 20, 20, 20, 20, 20, 0 _
, 74, 65, 73, 74, 5F, 70, 63, 35, 20, 20, 20, 20, 20, 20, 20, 0 _
, 74, 65, 73, 74, 5F, 70, 63, 31, 20, 20, 20, 20, 20, 20, 20, 0 _
, 74, 65, 73, 74, 5F, 70, 63, 37, 20, 20, 20, 20, 20, 20, 20, 0 _
, 0, 65, 73, 74, 5F, 70, 63, 38, 20, 20, 20, 20, 20, 20, 20, 0 _
, 74, 65, 73, 74, 5F, 70, 63, 39, 20, 20, 20, 20, 20, 20, 20, 0}
cmd.DataCount = 160
cmd.Data = d
replyReadProfileName(cmd)
End Sub
-------------------------------------------------------------------
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.38.86.243
→
03/27 17:22, , 1F
03/27 17:22, 1F
※ 編輯: laijackai 來自: 114.38.86.243 (03/27 20:19)
※ 編輯: laijackai 來自: 114.38.86.243 (03/27 20:28)
※ 編輯: laijackai 來自: 114.38.86.243 (03/27 20:29)
※ 編輯: laijackai 來自: 114.38.86.243 (03/27 20:29)
※ 編輯: laijackai 來自: 114.38.86.243 (03/27 20:33)