[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Error Loop Variable cannot be global
[Thread Prev] | [Thread Next]
- Subject: Re: Error Loop Variable cannot be global
- From: Jussi Lahtinen <jussi.lahtinen@xxxxxxxxx>
- Date: Mon, 18 Mar 2024 21:40:44 +0200
- To: user@xxxxxxxxxxxxxxxxxxxxxx
Just write it like this: Public $vList As String[] = ["a", "b", "c"] Public Sub Main() Dim $vStr As String For Each $vStr In $vList Debug $vStr Next End If you use variables with wider scope in loops, you will quickly end up with nasty bugs. Consider a situation where subs/functions happen to use the same variable in a loop --> bug. Or if each of them use the variable only once, then what's the point of the global scope! I see no good use for that. Thus I think it should be forbidden. Jussi
Error Loop Variable cannot be global | "Mayost Sharon" <sharon@xxxxxxxxx> |