Cannot use instance of a Type in For Next

enonod

Well-Known Member
Licensed User
Longtime User
I have a message that a regular variable must be used with a For/Next loop.
I was attempting...
B4X:
Type Fred(c as Byte, r as Byte)
Dim cr as Fred

For cr.c = 2 to 12
The message is clear but since cr.c can be set with a byte value I don't understand why this is not permitted without having to copy the value to/from another 'regular' variable.
Is there a reason for this or just not allowed?
 

enonod

Well-Known Member
Licensed User
Longtime User
@:Erel. Thank you.

@:mc73. I have a subroutine with a parameter as a Type being passed which works fine. I suddenly wish to use the same sub called from elsewhere when I only have available the individual c & r values so to pass them I had to copy them into the individual fields of the Type before passing them. I thought that rather than convert them I would use the Type fields in the first place and save a couple of lines of code. It obviously cannot be done and so back to the original.
 
Upvote 0
Top