P
Peter Lux
I have a structure that has an index that's used for an array of bitmaps.
The structure is:
Public Structure stik
Dim x As Integer
Dim y As Integer
'Dim bm As Bitmap
Dim pic As Integer
End Structure
and the array:
Dim bmArray(10) As Bitmap
and I have them collected in an arraylist of
Dim Stik_es As New ArrayList
I'm trying to loop thru them with the following code:
Private Sub Render()
g = pb.CreateGraphics()
Dim ostitch As stik
For Each ostitch In Stik_es
ostitch = CType(Stik_es(0), stik)
hBit = bmArray(ostitch.pic).GetHbitmap()
nuBM = Image.FromHbitmap(hBit)
g.DrawImage(nuBM, ostitch.x, ostitch.y)
Next ostitch
End Sub
The line I'm getting the error on is hBit =
bmArray(ostitch.pic).GetHbitmap() Here's the error:
Unhandled exception - System.NullReferenceException
Object reference not set to an instance of an object.
So what's null? The array is there, there are items in it. Might it be that
hBit (defined globally as
Dim hBit As IntPtr ) isn't initialized? I'm clueless.
Thanks in advance!!
The structure is:
Public Structure stik
Dim x As Integer
Dim y As Integer
'Dim bm As Bitmap
Dim pic As Integer
End Structure
and the array:
Dim bmArray(10) As Bitmap
and I have them collected in an arraylist of
Dim Stik_es As New ArrayList
I'm trying to loop thru them with the following code:
Private Sub Render()
g = pb.CreateGraphics()
Dim ostitch As stik
For Each ostitch In Stik_es
ostitch = CType(Stik_es(0), stik)
hBit = bmArray(ostitch.pic).GetHbitmap()
nuBM = Image.FromHbitmap(hBit)
g.DrawImage(nuBM, ostitch.x, ostitch.y)
Next ostitch
End Sub
The line I'm getting the error on is hBit =
bmArray(ostitch.pic).GetHbitmap() Here's the error:
Unhandled exception - System.NullReferenceException
Object reference not set to an instance of an object.
So what's null? The array is there, there are items in it. Might it be that
hBit (defined globally as
Dim hBit As IntPtr ) isn't initialized? I'm clueless.
Thanks in advance!!