andrewo
07-14-2001, 09:04 AM
Ok I am using a one dimensional array and it doesn't work properly.
I can't get the
Print Jack.Damage
working
Heres the code:
Private Type Person
health As Integer
damage As Integer
End Type
Private Sub Form_Load()
Dim Jack As Person
Jack.health = 100
Jack.damage = 14
End Sub
Private Sub Command1_Click()
Print Jack.damage
End Sub
~
BillSoo
07-14-2001, 11:40 AM
The problem is that Jack is Defined inside the Form_Load procedure. Therefore, it is LOCAL to that procedure (ie. unknown to other procedures). You need to make it either GLOBAL (visible to the entire project) or declare it at the module level (visible to all procedures on this form, but not outside the form).
Also, you should use Option Explicit. This will inform you when you try to use a variable that you haven't declared.
Option Explicit
Private Type Person
health As Integer
damage As Integer
End Type
Dim Jack As Person 'declared outside the procedure so it is now visible to other procedures on this form
Private Sub Form_Load()
Jack.health = 100
Jack.damage = 14
End Sub
Private Sub Command1_Click()
Print Jack.damage
End Sub
"I have a plan so cunning you could put a tail on it and call it a weasel!" - Edmund Blackadder
andrewo
07-14-2001, 10:30 PM
Finally its working!
I've been stuck on this for a while
~