Click here to Skip to main content
15,892,697 members
Home / Discussions / C#
   

C#

 
GeneralRe: Drawing/Graphics in C#: Draw shapes like rectangle & triangle when respective radio button is checked. Pin
Luc Pattyn1-Nov-09 0:26
sitebuilderLuc Pattyn1-Nov-09 0:26 
Questionquestion Pin
anooshe31-Oct-09 7:45
anooshe31-Oct-09 7:45 
Answernot a Pin
Luc Pattyn31-Oct-09 8:14
sitebuilderLuc Pattyn31-Oct-09 8:14 
AnswerRe: question Pin
dan!sh 31-Oct-09 9:34
professional dan!sh 31-Oct-09 9:34 
AnswerRe: question Pin
Pete O'Hanlon31-Oct-09 9:54
mvePete O'Hanlon31-Oct-09 9:54 
AnswerRe: question Pin
Richard MacCutchan31-Oct-09 10:49
mveRichard MacCutchan31-Oct-09 10:49 
AnswerRe: question Pin
Christian Graus31-Oct-09 11:13
protectorChristian Graus31-Oct-09 11:13 
QuestionVisual C# 2010 - Application Crashes At A Certain Time (Causing VS2010 To Crash As Well) Pin
Ben Magee31-Oct-09 6:47
Ben Magee31-Oct-09 6:47 
Hi, I'm making a Bingo Generator for a assignment, but it generates the last number, then should you click the button again it crashes, also crashing VS2010 so I don't get a error either. here's the button code:

var lineCount = 1;
           using (var reader = File.OpenText(@"saved.bingo"))
           {
               while (reader.ReadLine() != null)
               {
                   lineCount++;
               }
           }


               TextWriter saveCalled = new StreamWriter("saved.bingo");
               saveCalled.Write(called.Text);
               saveCalled.Close();

               TextReader loadSaved = new StreamReader("saved.bingo");
               string saved = loadSaved.ReadToEnd();
               loadSaved.Close();

               randomGenerated.generate();

               TextReader nextBingo = new StreamReader("bingoNext.bingo");
               string bingoNum = nextBingo.ReadToEnd();
               nextBingo.Close();

               bingoNum = bingoNum.Trim();

               if (saved.Contains(bingoNum) == true)
               {
                   randomGenerated.generate();
               }
               else
               {
                   TextReader tr = new StreamReader("saved.bingo");
                   string saveNm = tr.ReadToEnd();
                   tr.Close();

                   int saveNum = saveNm.Count();

                   if (saveNum >= 15)
                   {
                       button1.Visible = false;
                       MessageBox.Show("Game Over.");
                   }

                   newnum.Text = bingoNum;

                   TextReader nextCalled = new StreamReader("calledNext.bingo");
                   string calledNum = nextCalled.ReadToEnd();
                   nextCalled.Close();

                   called.Text = calledNum;
               }


and the generator code:

namespace openBingo
{
    public class randomGenerated
    {
        public static void generate()
        {
            System.Random linegrab = new System.Random(DateTime.Now.Millisecond);

            TextReader numRead = new StreamReader("numbers.bingo");

            ArrayList lines = new ArrayList();

            string line;

            while ((line = numRead.ReadLine()) != null)
            {
                lines.Add(line);
            }

            int randomIndex = linegrab.Next(lines.Count);


            string bingoNum = (lines[randomIndex]).ToString();

            numRead.Close();

            TextReader numbCheck = new StreamReader("saved.bingo");
            string saved = numbCheck.ReadToEnd();

            saved = saved.Trim();

            numbCheck.Close();



            if (saved.Contains(bingoNum))
            {
                randomGenerated.generate();  
            }
            else
            {
                TextWriter saveNum = new StreamWriter("saved.bingo");
                saveNum.WriteLine(bingoNum);
                saveNum.Close();

                string randBingo = bingoNum;

                TextWriter subNum = new StreamWriter("bingoNext.bingo");
                subNum.WriteLine(randBingo);
                subNum.Close();

                string newCalled = saved + " " + randBingo;
                

                TextWriter subCol = new StreamWriter("calledNext.bingo");
                subCol.WriteLine(newCalled);
                subCol.Close();
            }
        }
    }
}


It also gives no error on compiling either.

Thanks in advance, any more info you need to just say.

Ben.
AnswerRe: Visual C# 2010 - Application Crashes At A Certain Time (Causing VS2010 To Crash As Well) Pin
N a v a n e e t h31-Oct-09 7:25
N a v a n e e t h31-Oct-09 7:25 
AnswerRe: Visual C# 2010 - Application Crashes At A Certain Time (Causing VS2010 To Crash As Well) Pin
Luc Pattyn31-Oct-09 7:31
sitebuilderLuc Pattyn31-Oct-09 7:31 
GeneralRe: Visual C# 2010 - Application Crashes At A Certain Time (Causing VS2010 To Crash As Well) Pin
Ben Magee31-Oct-09 7:56
Ben Magee31-Oct-09 7:56 
GeneralRe: Visual C# 2010 - Application Crashes At A Certain Time (Causing VS2010 To Crash As Well) Pin
Luc Pattyn31-Oct-09 8:13
sitebuilderLuc Pattyn31-Oct-09 8:13 
GeneralRe: Visual C# 2010 - Application Crashes At A Certain Time (Causing VS2010 To Crash As Well) Pin
Ben Magee31-Oct-09 8:30
Ben Magee31-Oct-09 8:30 
GeneralRe: Visual C# 2010 - Application Crashes At A Certain Time (Causing VS2010 To Crash As Well) Pin
Richard MacCutchan31-Oct-09 10:50
mveRichard MacCutchan31-Oct-09 10:50 
GeneralRe: Visual C# 2010 - Application Crashes At A Certain Time (Causing VS2010 To Crash As Well) Pin
Ben Magee31-Oct-09 23:27
Ben Magee31-Oct-09 23:27 
GeneralRe: Visual C# 2010 - Application Crashes At A Certain Time (Causing VS2010 To Crash As Well) Pin
Richard MacCutchan31-Oct-09 23:59
mveRichard MacCutchan31-Oct-09 23:59 
AnswerRe: Visual C# 2010 - Application Crashes At A Certain Time (Causing VS2010 To Crash As Well) Pin
PIEBALDconsult31-Oct-09 13:20
mvePIEBALDconsult31-Oct-09 13:20 
GeneralRe: Visual C# 2010 - Application Crashes At A Certain Time (Causing VS2010 To Crash As Well) Pin
Ben Magee31-Oct-09 23:09
Ben Magee31-Oct-09 23:09 
GeneralRe: Visual C# 2010 - Application Crashes At A Certain Time (Causing VS2010 To Crash As Well) Pin
PIEBALDconsult1-Nov-09 3:29
mvePIEBALDconsult1-Nov-09 3:29 
QuestionWeb.sitemap updating, but Menu is not updating... why??? Pin
Timothy OBrien31-Oct-09 6:46
Timothy OBrien31-Oct-09 6:46 
QuestionHow i can make my mobile as modem by c# program Pin
Abdaqader31-Oct-09 5:33
Abdaqader31-Oct-09 5:33 
AnswerRe: How i can make my mobile as modem by c# program Pin
Henry Minute31-Oct-09 6:04
Henry Minute31-Oct-09 6:04 
Questionhow to get the throughput of my hard disk during the latest period of time Pin
sinron31-Oct-09 4:52
sinron31-Oct-09 4:52 
AnswerRe: how to get the throughput of my hard disk during the latest period of time Pin
Randor 1-Nov-09 11:26
professional Randor 1-Nov-09 11:26 
GeneralRe: how to get the throughput of my hard disk during the latest period of time Pin
sinron2-Nov-09 0:14
sinron2-Nov-09 0:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.