Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
namespace StudentGrades
{
    public partial class frmgrades : Form
    {

        private static readonly object initalizeComponent;


        private static void Main(string[] args)
        {
            _ = initalizeComponent;
        }
        private void FromGrades_load(object sender, EventArgs e)
        {
            string filePath = @"C:\Users\DLShi\OneDrive\Documents\Visual Studio 2022\Templates\ProjectTemplates\StudentGrades\StudentGrades\Grades.txt";
            if (File.Exists(filePath))
            {
                StreamReader stream = new StreamReader(filePath);
                txtGrades.AppendText(stream.ReadToEnd());
                _ = Console.ReadLine();
            }

            else
            {
                _ = MessageBox.Show("There was a problem loading the files");
                Console.ReadLine();
            }

        }
    }

}


What I have tried:

I have tried debugging and analyzing my code with no errors.
Posted
Updated 11-Dec-22 10:16am
v2
Comments
[no name] 11-Dec-22 12:53pm    
Based on your expectations, programs need to do certain things. We don't know what you expect to happen after your program starts. A program only shows "results" if told to.
Donna Shipp 11-Dec-22 13:06pm    
I'm expecting to see the text file information in a text box.
Dave Kreskowiak 11-Dec-22 15:49pm    
Is this a Windows Forms app or a Console app? Your code is very confused and trying to use both.

Do you get any messages at all when it runs? Does that MessageBox.Show call display anything?

If in a Windows Forms app, those calls to Console.ReadLine will do nothing at all, they can be removed.
Donna Shipp 11-Dec-22 16:19pm    
Here is what I'm trying to do: Create a program that stores student grades in a text file. The file should contain the name, ID number, class taken and grade of every student. Allow the user to load a grade file and display its contents in a read-only TextBox. The entries should be displayed in the following format:
LastName, FirstName: ID# Class Grade

Some sample data:
Jones, Bob: 1 "Introduction to Computer Science" "A-"
Johnson, Sarah: 2 "Data Structures" "B+"
Smith, Sam: 3 Data Structures" "C"

So I created a "Form" with a text box and a text file with the information then I created my coding. When debugging, there are no errors but the text file is not showing in the text box. I am very new to C# so this is why I'm having a hard time. Any assistance would be greatly appreciated.
Dave Kreskowiak 11-Dec-22 16:33pm    
OK, scrap the code you have and start over. There is such much wrong with the code you posted that it is not practical to try to salvage it. It's quicker to just start from scratch.

Create a new Windows Forms project and you at least have a known good starting point.

Quote:
The program '[9460] StudentGrades.exe' has exited with code 0 (0x0).
When a program exits with code 0, it means there was no problem with the code execution.

Quote:
Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
That is a setting that you have enabled in Visual Studio, and thus, the debugger will not load the symbols for dependencies. The System.dll and System.Drawing.dll is not a module that you are developing, rather you are depending upon them. You can disable that: Debug user code with Just My Code - Visual Studio (Windows) | Microsoft Learn[^].
Quote:
my loading screen not showing my results?
Are you printing something to the console? Please share the code that you wrote for the program and what output you are expecting.
 
Share this answer
 
Comments
Donna Shipp 11-Dec-22 12:54pm    
Dave Kreskowiak 11-Dec-22 15:07pm    
Sorry, I tried editing your post to put PRE tags around it and CP removed all the code and kept the PRE tags.

Please edit your original post above by clicking the green "Improve question" link and put the code in there surrounded by PRE tags.
Donna Shipp 11-Dec-22 13:09pm    
I'm trying to get the information from the text file to show in a text box.
George Swan 11-Dec-22 13:30pm    
I suggest that you check that Grades.txt is not an empty file
Donna Shipp 11-Dec-22 13:49pm    
It is not empty.
C#
public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
    }


Your Form should look something like what is shown above.
You can't just turn a console app into a windows form app.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900