Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8195253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:04:28+00:00 2026-06-07T05:04:28+00:00

This is the form code and every time I test some inputs, the application

  • 0

This is the form code and every time I test some inputs, the application will open and then immediately close and I can’t figure out what is causing it.

  namespace Assignment2
  {
public partial class IsmClassForm : Form
{
    public IsmClassForm()
    {

        InitializeComponent();
    }
    private void IsmClassForm_Load(object sender, EventArgs e)
    {
    }

    protected Student m_student;
    protected Course m_course;
    protected IsmClassForm m_next;
    protected EnrollmentForm m_home;

     public bool TestPrerequisites()

    {
        if (!m_student.Record.MeetsPrerequisites(m_course.Number))
        {
            MessageBox.Show("The registrar reports that you don't meet the prerequisites for " + m_course.Prefix + m_course.Number.ToString());
            m_student.PridePoints = m_student.PridePoints - 5;
            m_student.Record.Remove(m_course);
            return false;
        }
        return true;
    }
    public string Description
    {
        get
        {
            return textDescription.Text;
        }
        set
        {
            textDescription.Text = value;
        }
    }

    public string Title
    {
        get
        {
            return this.Text;
        }
        set
        {
            this.Text = value;
        }
    }
    public string Welcome
    {
        get
        {
            return labelWelcome.Text;
        }
        set
        {
            labelWelcome.Text = value;
        }
    }



    public bool Initialize(Student student, int course, IsmClassForm next, EnrollmentForm home)
    {
        if (student == null) return false;
        m_student = student;
        m_next = next;
        m_home = home;
        m_course = m_student.Record.FindEnrolled(course);
        if (m_course == null)
        {
            return false;
        }

        labelCourse.Text = m_course.Prefix + "-" + m_course.Number.ToString();
        return TestPrerequisites();

    }


    public enum DropMode
    {
        FreeDrop, PayDrop, Withdraw, NoDrop
    };
    DropMode mState = DropMode.FreeDrop;
    public DropMode Drop
    {
        get
        {
            return mState;
        }
        set
        {
            mState = value;
            UpdateDrop();
        }
    }

    public void UpdateDrop()
    {
        switch (Drop)
        {
            case DropMode.FreeDrop:
                buttonDrop.Text = "Drop";
                break;
            case DropMode.PayDrop:
                buttonDrop.Text = "Drop";
                break;
            case DropMode.Withdraw:
                buttonDrop.Text = "Withdraw";
                break;
            case DropMode.NoDrop:
                buttonDrop.Text = "Done";
                break;
        }

    }

    protected void buttonDrop_Click(object sender, EventArgs e)
    {
        switch (Drop)
        {
            case DropMode.FreeDrop:
                m_student.PridePoints = m_student.PridePoints - 5;
                m_student.Record.Remove(m_course);
                m_course = null;
                break;
            case DropMode.PayDrop:
                m_student.PridePoints = m_student.PridePoints - 10;
                m_student.WealthPoints = m_student.WealthPoints - 500;
                m_student.Record.Remove(m_course);
                m_course = null;
                break;
            case DropMode.Withdraw:
                m_student.PridePoints = m_student.PridePoints - 50;
                m_student.WealthPoints = m_student.WealthPoints - 500;
                m_course.Grade = "W";
                break;
            case DropMode.NoDrop:
                m_student.WealthPoints = m_student.WealthPoints - 500;
                break;
        }
        Close();


    }

    protected void IsmClassForm_FormClosed(object sender, FormClosedEventArgs e)
    {
        if (e.CloseReason == CloseReason.UserClosing)
        {
            //The student not having a grade suggest the buttons were ignored
            if (m_course != null && m_course.Grade == null)
            {
                m_course.Grade = "F";
                m_student.PridePoints = m_student.PridePoints - 100;
                m_student.WealthPoints = m_student.WealthPoints - 500;
            }
            if (m_next != null) m_next.Show();
            else if (m_home != null) m_home.Show();
        }






    }

And here are some test inputs:

 static void TestIsmClassForm()
    {
        Student tjt1 = new Student("Travis Todd");
        tjt1.Record = new Transcript();
        tjt1.Record.Add(new Course(1, 3113, "B", false));
        tjt1.Record.Add(new Course(1, 3232, "C", false));
        tjt1.Record.Add(new Course(2, 3113, "A", true));
        tjt1.Record.Add(new Course(2, 3232, null, true));
        tjt1.Record.Add(new Course(2, 4220, null, true));
        IsmClassForm f4220 = new IsmClassForm();
        IsmClassForm f3232 = new IsmClassForm();
        IsmClassForm f4212 = new IsmClassForm();
        f4212.Initialize(tjt1, 4212, f3232, null);
        f3232.Initialize(tjt1, 3232, f4220, null);
        f4220.Initialize(tjt1, 4220, null, null);
        f4212.Show();
    }

This does use some other classes in the project and their forms, but I the other functions all work and these is the only problem I have found so far. Am I missing something glaringly obvious?

Thank you,
Travis

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T05:04:32+00:00Added an answer on June 7, 2026 at 5:04 am

    You have two ways to achieve this;

    Given your entry method:

    public static void Main()     
    {         
        TestIsmClassForm();    
    } 
    

    You can use Application.Run or Form.ShowDialog:

    static void TestIsmClassForm()
    {
        ...All of your original code...
    
        Application.Run(f4212.Show());
    
        //OR
    
        f4212.ShowDialog()
    
    }
    

    What is happening right now is that Form.Show is non-blocking – the application calls it, continues on out of the method, and closes.

    Application.Run will show the form and wait until it closes before exiting the application. Form.ShowDialog() will block the calling method until the form is closed.

    Application.Run is preferred because it guarantees the form used as the application host is marshalled in the “Main” or “GUI” thread. ShowDialog() makes no guarantee when run direct from Main()(Application.MessageLoop is false) and it is possible for some surprisingly annoying threading bugs to happen – so the majority of the time Application.Run is the best way to achieve what you are doing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone explain why this code: {% form_theme form _self %} {% block avo_gallery_upload_widget
I am attempting to test some code that uses Request.Item(key) but I can not
I have this form submit code: Event.observe(window, 'load', init, false); function init() { Event.observe('addressForm',
I grabbed this code form JCarousel and just trying to understand these lines below.
I have a delphi 7 form: and my code: when I run this form
Hello i have this form filling javascript: function onLine(code,nn) { document.writeform.bericht.value+=code; document.writeform.bericht.focus(); document.writeform.nickname.value+=nn; write1();
I have the following code: echo ' <td> <input type=button name=delete value=X onclick=clearSelection(this.form, '.$type.');this.form.submit();
With this code: public partial class Form1 : Form { private static readonly int
this line of the code makes the form see-through User32Wrappers.SetLayeredWindowAttributes(Me.Handle, 0, _ 255 *
This code works anywhere else.. form load, button click, etc. But when I add

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.