I’m having a problem when using variables in object names.
I have a Public class which is called “Tank”
In that class, there is a public property called “direction” of an integer type.
I keep getting the error:
“Tank is a type and cannot be used as an expression”
What I’m doing wrong here ?
Public Class mainroutines()
' Create Instances of tank
Private Tank1 As New Tank()
Private Tank2 As New Tank()
'Loop trough objects and set the property value
dim i as integer
For i = 1 to 2
Tank(i).direction = 1
next i
End class
Well,
Tank(i)is not equivalent toTank1. You would need to make a list of tanks, add your instances to it, and access them that way.