Teen Programmers Unite  
 

 

Return to forum top

Visual Basic 6.0 help please

Posted by AboutTPUCredits [send private reply] at June 13, 2002, 02:16:40 AM

I am making a program that has three doors on it. The three doors need to be made randomly openable...so if door one is unlocked, door two and three are also locked. could anyone give any suggestions?

Posted by AboutTPUCredits [send private reply] at June 13, 2002, 02:21:38 AM

the doors are images by the way

Posted by metamorphic [send private reply] at June 13, 2002, 04:03:14 AM

just use an if statment

if doorone.image = "unlocked.bmp" then
   doortwo.image = "locked.bmp"
   doorthree.image = "locked.bmp"
elseif doortwo.image = "unlocked.bmp" then
   doorone.image = "locked.bmp"
   doorthree.image = "locked.bmp"
else
   doorone.image = "locked.bmp"
   doortwo.image = "locked.bmp"
end if
Posted by buzgub [send private reply] at June 13, 2002, 04:14:00 AM

You'll need to decide how a door is going to open, too. It sounds like you're *way* beyond your level of knowledge here, though, so if you have a teacher you should talk to them. If you're trying to teach yourself, you should try something smaller.

Good luck.

Posted by Psion [send private reply] at June 13, 2002, 09:33:04 AM

But I like your name. It's very artsy.

Posted by gian [send private reply] at June 13, 2002, 08:16:20 PM

I was about to comment about that one...

Posted by CodeRed [send private reply] at June 13, 2002, 09:43:53 PM

This is extremely easy

unlocked = rand()%3;
if(unlocked==1){door1=true; door2=false; door3=false;}
else if(unlocked==2){door1=false; door2=true; door3=false;}
else {door1=false; door2=false; door3=true;}

Then just handle the images later, it really isn't difficult

You must be logged in to post messages and see which you have already read.

Log on
Username:
Password:
Save for later automatic logon

Register as a new user
 
Copyright TPU 2002. See the Credits and About TPU for more information.