hi, for school we are to create a game in vb (master mind)
so anyway i want to make my code very condensed, now i have used a variety of different programming tools, but vb is new to me, i want to assign an array to my objects so i can make my code small
at the moment the object is a label, so i am not sure how to assign it
either
VB Code:
Dim slotname(5) As Object
or
then in one of my scripts i run this code
VB Code:
slotname(0) = lbl_slot1 'names of my labels in vb
slotname(1) = lbl_slot2
slotname(2) = lbl_slot3
slotname(3) = lbl_slot4
slotname(4) = lbl_slot5
in another script i run this code
VB Code:
While colour_setup < 4
colourslot_rand(colour_setup) = Int(Rnd * 5)
colourslot(colour_setup) = colourslot_rand(colour_setup)
slotname(colour_setup).BackColor = colourslot(colour_setup)
colour_setup = colour_setup + 1
Wend
Now in this code basically this will pick a random colour and assign it to the labels background colour
whenever i run this script i get the error
Run-time error '91'
Object variable or With block variable not set
and it then proceeds to go to this line of code
can someone please help me to gain a better understanding of how vb works in this sence?