I tried this...
and then this...Code:Public Class frmMain Dim pc() As CardPictureBox = {picCard0, picCard1, picCard2, picCard3, picCard4, picCard5, picCard6, picCard7, picCard8, picCard9, picCard10, picCard11, picCard12, picCard13, picCard14, picCard15, picCard16, picCard17, picCard18, picCard19, picCard20, picCard21, picCard22}
When I write the code at design time, I have no problems. I get intellisense for all my properties. Everything is good. But when I run the program, the .Image code creates a Null Error.Code:Private Sub StartNewGame() pc(1).Image = My.Resources.b1pr
I don't understand why because the following code (with the array inside the Sub) works just fine. If I remove the Dim pc() from the MakeControllsVisibleSub, I get the null error again.
I want to Dim the pc() array one time only. I want it to be global. What am I doing wrong?Code:Private Sub MakeControlsVisible() Dim pc() As CardPictureBox = {picCard0, picCard1, picCard2, picCard3, picCard4, picCard5, picCard6, picCard7, picCard8, picCard9, picCard10, picCard11, picCard12, picCard13, picCard14, picCard15, picCard16, picCard17, picCard18, picCard19, picCard20, picCard21, picCard22} For i As Integer = 0 To 22 pc(i).Visible = True Next End Sub




Reply With Quote