Join 150,397 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 1,014 people online right now. Registration is fast and FREE... Join Now!
I must warn you though, it WILL look retarded to most of you because I'm sure there are better ways, however right now I'm just looking for functionality not optimization. Here's where you guys come in, how can I make this code much much shorter. Shorter = better, right?
And here's a screenshot:
Finished Code:
CODE
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;
namespace BingoConLabels { public partial class Form1 : Form { Random RandomClass = new Random(); string[] numllamados = new string[15];
Ok, this a pretty good trick Label label = (Label)Controls["label" + i];, most folks don't figure that one out right away. If you were to place all those lables inside a group box, you could just loop through the child controls. I'd use nicer names, like labBoard1Slot1 or something. Even better, load up a reference array for them at the begining.
I don't think this business has any hope of giving you the result you want:
Ok, this a pretty good trick Label label = (Label)Controls["label" + i];, most folks don't figure that one out right away. If you were to place all those lables inside a group box, you could just loop through the child controls. I'd use nicer names, like labBoard1Slot1 or something. Even better, load up a reference array for them at the begining.
I don't think this business has any hope of giving you the result you want:
Aren't you looking for lines across, down, or diagnal? Not just everything filled in?
One more thing, do you want to allow those random numbers repeated on the same board? e.g. 84 appears twice in the top board.
You asked for it. So far so good, though.
I would like to implement looking for across, diagonals rows, etc. But I think that's too hard to do with labels. Is there a better tool to use instead of labels for this particular thing?
How would I go about checking repeated numbers? I noticed that but I was too tired to fix it.
Yes, it helped. But most of the stuff is chinese to me!
I'll try some of the stuff out and update the first post. Maybe I'll finish the Bingo game with even more features.
So far things to do are: *Add money to buy bingo cards, lose money, etc. *Check full row, column, check diagonals. *Play a sound file when someone makes a bingo.
How would I play a sound file? I can't see anything in the properties window of the form. :S