❔ How can i clear the text of an array of labels

9 Replies
Hashashin023
Hashashin023OP2y ago
FusedQyou
FusedQyou2y ago
You iterate the array using a for-loop, and set the string to ""
Hashashin023
Hashashin023OP2y ago
so it work but we need to go back to the first row of the label so that the letter S come back
FusedQyou
FusedQyou2y ago
Then you need to skip the first index if (i == 0) continue; Little side note: I think you can make this much easier
Hashashin023
Hashashin023OP2y ago
FusedQyou
FusedQyou2y ago
That means the index is out of bounds. the index must match an entry in the array So Timer is not a valid index
Hashashin023
Hashashin023OP2y ago
but how do we fix that? owh i found iot Timer = 0 for (int i = 0; i < Labels.Length; i++) { Labels[i].Text = ""; if (i == 0) continue; Timer = 0; } Labels[0].Text = strLingo.Substring(0, 1); bro thanks really apriciated your help!
FusedQyou
FusedQyou2y ago
Geen probleem 🙃 It might be easier to use a List as it has some more capabilities and it's not as strict In your case it might be a good idea to keep a List of sentences that the user has tried, so that you can just use the next entry rather than removing the current one Not sure how you can do that in a forms project though
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server