Hi,
there is quite a bit of code and some is confidential;
unfortunately I cannot post it. But any speculation
would be helpful.
Denis
Here is the entire class:
Imports System.Text
Imports System.Runtime.InteropServices
Imports System.Reflection
Public Class GetAttribIDandTextsRT
Private structSize As Integer
Private longSize As Integer
Private charSize As Integer
Private theAttribID(39) As Integer 'LONG AttribID[40];
Private theAttribText(39) As String 'char AttribText
[40][100];
Private theKnownEquip(39) As Integer 'BOOL KnownEquip
[40];
Private theAttribGrpID(39) As Integer 'LONG
AttribGrpID[40];
Private arrayStart As Integer
Public Sub New(ByVal ptr As IntPtr)
structSize = DBAccess.GetAttribIDandTextsSize()
charSize = DBAccess.charSize()
longSize = DBAccess.LONGSize()
Dim bData(structSize) As Byte
Marshal.Copy(ptr, bData, 0, structSize)
arrayStart = 0
initAttribID(bData)
initAttribText(bData)
initKnownEquip(bData)
initAttribGrpID(bData)
End Sub
'Public Getter Functions
ReadOnly Property AttribID(ByVal i As Integer) As
Integer
Get
Return theAttribID(i)
End Get
End Property
ReadOnly Property AttribText(ByVal i As Integer) As
String
Get
Return theAttribText(i)
End Get
End Property
ReadOnly Property KnownEquip(ByVal i As Integer) As
Boolean
Get
If (theKnownEquip(i) > 0) Then
Return True
Else
Return False
End If
End Get
End Property
ReadOnly Property AttribGrpID(ByVal i As Integer) As
Integer
Get
Return theAttribGrpID(i)
End Get
End Property
'Private init subs
Private Sub initAttribID(ByVal bData() As Byte)
For i As Integer = 0 To 39
theAttribID(i) = BitConverter.ToInt32(bData,
i * longSize)
Next i
arrayStart += 40 * longSize
End Sub
Private Sub initAttribText(ByVal bData() As Byte)
Dim pos As Integer = charSize * 100
For i As Integer = 0 To 39
theAttribText(i) = _
System.Text.ASCIIEncoding.ASCII.GetString
(bData, arrayStart + (i * pos), (arrayStart + (i * pos))
+ 99)
Next i
arrayStart += (40 * pos)
End Sub
Private Sub initKnownEquip(ByVal bData() As Byte)
For i As Integer = 0 To 39
theKnownEquip(i) = BitConverter.ToInt32
(bData, i * longSize + arrayStart)
Next i
arrayStart += 40 * longSize
End Sub
Private Sub initAttribGrpID(ByVal bData() As Byte)
For i As Integer = 0 To 39
theAttribGrpID(i) = BitConverter.ToInt32
(bData, i * longSize + arrayStart)
Next i
End Sub
End Class
-----Original Message-----
"Denis C" <an*******@discussions.microsoft.com> schrieb For i As Integer = 0 To 39
theAttribText(i) = _
System.Text.ASCIIEncoding.ASCII.GetString
(bData, arrayStart + (i * pos),
(arrayStart + (i * pos)) + 99)
Next i
arrayStart += (40 * pos)
End Sub
The byte array bData is of length 4481.
The value of i at the point of the error is 21.
The value of arrayStart is 160.
The value of pos is 100.
So the indexes at the point of the error are 2260,
2359.
Could you please send compilable source code? Otherwise
I (we) first have tofind out what's missing and how to make the code run.
Thx.
--
Armin
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
.