To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
VBForums  

VB Wire News
Part 10 of the Visual Basic .NET 2010 Express Tutorial Complete!
How to Use the Visual Studio Code Analysis Tool FxCop
Article :: Interview with Andrei Alexandrescu (Part 3 of 3)
Introducing Visual Studio LightSwitch
Visual Studio LightSwitch Beta 1 is Available



Go Back   VBForums > Visual Basic > Visual Basic 6 and Earlier

Reply Post New Thread
 
Thread Tools Display Modes
Old Aug 7th, 2004, 08:02 PM   #1
jdbb
New Member
 
Join Date: Aug 04
Posts: 9
jdbb is an unknown quantity at this point (<10)
Problem with a bingo game!!! Help

i cant think of more code to write for such a simple game. When i started writing this program i didnt know so much about control arrays so i had to make a whole lotta code for minimum functions.

the problem is when i try to make the numbers in a same line diffrent i get an overflow and and error.

Plus, there are 2 cartons and whenever theres the same number in both of em, it only marks it in the first...

Any help is good....

heres the whole folder
Attached Files
File Type: zip the bingo program.zip (34.4 KB, 15 views)
jdbb is offline   Reply With Quote
Old Aug 8th, 2004, 12:42 AM   #2
adzzzz
Hyperactive Member
 
Join Date: Apr 02
Location: UK
Posts: 506
adzzzz is an unknown quantity at this point (<10)
I just had to change the code in your Command4_Click event:
VB Code:
  1. Private Sub Command4_Click()
  2.   Dim l As Long
  3.   Randomize
  4.   b = 1 + Int(Rnd * 99)
  5.   Text1.Text = b
  6.  
  7.   Label20.Caption = " Nobody's got the " & b
  8.   For l = 0 To Label6.UBound
  9.     If Label6(l).Caption = b Then
  10.       Label6(l).BackColor = vbRed
  11.       Label20.Caption = ""
  12.     End If
  13.   Next l
  14. End Sub
Not only does this look alot tidier but it fixes the problem of only one cartoon being highlighted for a raised number. I replaced the RGB function with vbRed simply because I tend avoid it's usage where possible.
adzzzz is offline   Reply With Quote
Old Aug 8th, 2004, 10:11 AM   #3
jdbb
New Member
 
Join Date: Aug 04
Posts: 9
jdbb is an unknown quantity at this point (<10)
thanks a bunch...can you tell me exactly what u did'?
jdbb is offline   Reply With Quote
Old Aug 8th, 2004, 02:38 PM   #4
adzzzz
Hyperactive Member
 
Join Date: Apr 02
Location: UK
Posts: 506
adzzzz is an unknown quantity at this point (<10)
Well you had the code to change each of the label background colours in a long chain of elseif statements, thus if one label was found to have the correct number the "if loop" would end and no other labels would be checked.

Try to imagine the workings of if statements as below, if one condition of the "elseif chain" is met then no others are compared:
Code:
IF label1.caption = "one" THEN
   ..do something
  goto DONEIF
ELSEIF  label1.caption = "two" THEN
   ..do something
  goto DONEIF
ELSEIF label2.caption = "one" THEN
   ..do something
  goto DONEIF
ELSEIF  label2.caption = "two" THEN
   ..do something
  goto DONEIF
END IF

DONEIF:
IF the above was implemented in VB or any other programming language, the caption of label2 would never be checked if the caption of label 1 was one or two.

With my code the for loop checks every label in the control array and if it has the correct number then the background colour is changed.
adzzzz is offline   Reply With Quote
Old Aug 8th, 2004, 02:41 PM   #5
Merri
VB6, XHTML & CSS hobbyist
 
Merri's Avatar
 
Join Date: Oct 02
Location: Finland
Posts: 6,440
Merri is a name known to all (1000+)Merri is a name known to all (1000+)Merri is a name known to all (1000+)Merri is a name known to all (1000+)Merri is a name known to all (1000+)Merri is a name known to all (1000+)Merri is a name known to all (1000+)Merri is a name known to all (1000+)
Why you have Goto DONEIF there? The code would jump there even if there wouldn't be any gotos.
__________________
Unicode classes, functions... in Visual Basic 6

VB6 in occasional use. I'm mostly HTML, CSS & JavaScript these days.
« Antec Sonata II: Core 2 Duo E7400, ASRock P45TS, Asus EN9600GT 512 MB, 4 GB, 1.25 TB »
« OS: Windows 7 | Laptop: Amilo Pi 2530-12P| Netbook: Asus EEE 901 »
Merri is offline   Reply With Quote
Reply

Go Back   VBForums > Visual Basic > Visual Basic 6 and Earlier


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 05:18 AM.





Acceptable Use Policy

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.