There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Software Development
Tag Cloud
audio blue screen boot bsod computer cpu crash dell desktop driver drivers error excel external hard drive firefox freezes freezing hard drive hardware hijackthis internet internet explorer itunes laptop mac malware motherboard mouse network networking outlook 2007 power printer problem ram router screen slow sound trojan usb virus vista vista 32-bit windows windows vista windows xp winxp wireless wmp
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Looping Objects in VB.NET


Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
willydigger's Avatar
Senior Member with 112 posts.
 
Join Date: Jul 2003
20-Dec-2003, 01:23 PM #1
Looping Objects in VB.NET
Hey guys, it's your friendly neighborhood willydigger here,

I just finished my intro to VB college course and I have a question. The final project was a TicTacToe game. In the game I made a grid of label (Label1, Label2, Label3, etc).

When the player or the computer would win, I would change the forecolor of the winning trio from Black to Red to highlight the winning combo. When the game reset I returned the forecolor to Black.

My question is this, can you alter an object name in order to loop?
In order to change the color back to Black I had to write the following:

Label1.ForeColor = Color.Black
Label2.ForeColor = Color.Black
Label3.ForeColor = Color.Black
etc.

Is it possible to do something where I could write one line of code and loop through 1 - 9?

Thanks, any help would be great!

willy
MustBNuts's Avatar
Distinguished Member with 2,017 posts.
 
Join Date: Aug 2003
Location: Nevada
20-Dec-2003, 03:03 PM #2
If you had set up the labels as an array you could have had code that looked something like this:

for x=1 to whatever
label(x).forecolor=vbBlack
next x

Hope this helps,

MBN

PS: I'm not sure if that is a new VB.NET syntax, but in VB 6, you can change color using the syntax I did....
__________________
I'll burn that bridge when I get to it!
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 08:49 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.