Results 1 to 4 of 4

Thread: [RESOLVED] Checking Dialog result

  1. #1

    Thread Starter
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Resolved [RESOLVED] Checking Dialog result

    Continuing with my project:

    I have this code:

    DialogResult result6;
    Boolean result7;
    result6 = MessageBox.Show("Do you want to do an amortization schedule?", "TVAL", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
    if (result6 = DialogResult.Yes)
    result7 = true;
    else
    result7 = false;

    if (result7 = true)
    {
    txtLoanAmount.Text = PVal.ToString("N2");
    txtTerm.Text = TotPmts.ToString("N2");
    txtRate.Text = APR.ToString("N5");
    txtPayment.Text = Payment.ToString("N2");

    MessageBox.Show("Fill in dates, select the base, and press [Compute Amortization Schedule] button", "TVAL", MessageBoxButtons.OK, MessageBoxIcon.Information);
    this.Refresh();
    }


    I am getting this error (on the result6 = Dialogresult.Yes)

    Error 1 Cannot implicitly convert type 'System.Windows.Forms.DialogResult' to 'bool' I:\VB NET Source Code\C#\TVAL\TVAL\TVAL\Form1.cs 1257 17 TVAL


    I am getting this error on the result7 = true line:

    Warning 2 Assignment in conditional expression is always constant; did you mean to use == instead of = ? I:\VB NET Source Code\C#\TVAL\TVAL\TVAL\Form1.cs 1262 17 TVAL

    The VB6 code was much easier (I am probably doing this wrong):

    amort = MsgBox("Your payment will be $" & Format(Payment, Fmt) & " per month." & vbCrLf & vbCrLf & "Do you want to do an amortization schedule?", vbYesNo)
    If amort = vbYes Then
    txtLoanAmount.Text = PVal
    txtTerm.Text = TotPmts
    txtRate.Text = APR * 100
    txtPayment.Text = Format(Payment, Fmt)
    MainMenu.Refresh
    End If
    ===================================================
    If your question has been answered, mark the thread as [RESOLVED]

  2. #2

    Thread Starter
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: Checking Dialog result

    Got it to work:

    if (MessageBox.Show("Do you want to do an amortization schedule?", "TVAL", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
    {
    txtLoanAmount.Text = PVal.ToString("N2");
    txtTerm.Text = TotPmts.ToString("N2");
    txtRate.Text = APR.ToString("N5");
    txtPayment.Text = Payment.ToString("N2");

    MessageBox.Show("Fill in dates, select the base, and press [Compute Amortization Schedule] button", "TVAL", MessageBoxButtons.OK, MessageBoxIcon.Information);
    this.Refresh();
    }
    ===================================================
    If your question has been answered, mark the thread as [RESOLVED]

  3. #3
    Registered User nmadd's Avatar
    Join Date
    Jun 2007
    Location
    U.S.A.
    Posts
    1,676

    Re: [RESOLVED] Checking Dialog result

    "=" is both the assignment operator and the equality operator in VB, however, as you found out they are two different things in C#. How's the project coming along?

  4. #4

    Thread Starter
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: [RESOLVED] Checking Dialog result

    It is coming along. I have 5 buttons and a listview on one form. With each control, I learn something new.

    The whole reason for this 'exercise' is that we are getting new barcode scanners. The programs (which I will have to write) will be in C#. My background is in VB (only moved a couple apps to VB2005). I chose this app to learn C# on because it is small, straight forward, and encompasses most things that I will run into (except database accessing).

    Thanks for all the help.
    ===================================================
    If your question has been answered, mark the thread as [RESOLVED]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width