hey im having a little trouble ,i have five blue tanks on the form and ive tried
to setup a dead or alive .state .im missing something because i keep getting errors .methed or data member not found on .state part .its probly simple
but i cant see it
thanks
Code:
Option Explicit
Private Enum bouncedir
upLeft = 1
upright = 2
downLeft = 3
downright = 4
up = 5
down = 6
Left = 7
Right = 8
End Enum
Private Const ALIVE As Integer = 10
Private Const DEAD As Integer = 20
Private Const max_tanks As Integer = 5
Private Const MAX_DISTANCE = 200
Dim Running As Boolean
Public state As Integer
Private xdir(0) As bouncedir '~~~~ using an array
Private ydir(0) As bouncedir '~~~~ using an array
Sub Inittanks()
' init variables for start-up
Dim i As Integer
For i = 0 To max_tanks
With blue(i)
.state = ALIVE
End With
Next i
End Sub
Last edited by flyhigh; Aug 12th, 2010 at 12:23 PM.
...I don't see where you declared Blue() or what data type it is
thats where i keep getting problems
Of course. You have to declare Blue() as something. Do you have a class or user-defined type (UDT) that Blue is suppose to be? If so, you are missing:
Dim Blue(0 To max_Tanks) As whateverBlueIs
Insomnia is just a byproduct of, "It can't be done"
i get this error =member already exists in a object module from which this object module derives.
blue(0) is number 1 tank image
Code:
Option Explicit
Private Enum bouncedir
upLeft = 1
upright = 2
downLeft = 3
downright = 4
up = 5
down = 6
Left = 7
Right = 8
End Enum
Private Const ALIVE As Integer = 10
Private Const DEAD As Integer = 20
Private Const max_tanks As Integer = 5
Private Const MAX_DISTANCE = 200
Dim Running As Boolean
Private xdir(0) As bouncedir '~~~~ using an array
Private ydir(0) As bouncedir '~~~~ using an array
Dim blue(0 To 4) As tanks
Private Type tanks
State As Integer
End Type
Sub Inittanks()
' init variables for start-up
Dim i As Integer
For i = 0 To max_tanks
With blue(i)
.State = ALIVE
End With
Next i
End Sub
Sub Run()
While Running
DoEvents
Wend
End Sub
Private Sub start_Click()
start.Enabled = False
start.Visible = False
Inittanks
Running = True
Run
End Sub
Private Sub Form_Unload(Cancel As Integer)
Running = False
End Sub
Private Sub Form_Load()
Randomize
Dim X As Integer
X = (Int(Rnd * 8) + 1) 'Start in a random direction
xdir(0) = X
Dim Y As Integer
Y = (Int(Rnd * 8) + 1) 'Start in a random direction
ydir(0) = Y
End Sub
I haven't had time to try your project, but in the mean time look at these possible problems.
1. I don't know if ALIVE or DEAD is also a property name of something in your project. You may want to try renaming them to something else like, maybe, STATE_ALIVE or STATE_DEAD?
2. Look out for your enums. Left is a VB property & that might be causing the problems.
Suggest renaming those enum members too, maybe: dir_Right, dir_Up, dir_Left, etc, etc
Last edited by LaVolpe; Aug 12th, 2010 at 02:43 PM.
Reason: typos
Insomnia is just a byproduct of, "It can't be done"