Note that there are some explanatory texts on larger screens.

plurals
  1. POC# Visual Basic Inheritance
    primarykey
    data
    text
    <p>I'm just getting started with C# and I've been stuck on this problem for two weeks. I have a main form that gets values from a class and a subclass. My problem is that when I try to create an object of the CorporateClass VB tells me that two of my variables (CarSizeInteger and DiscountInteger) are unassigned. My question is why. I implemented them earlier in the program. Help! I'm hopelessly stuck!</p> <pre><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 EX02_CarRentals { public partial class RentalForm : Form { public RentalForm() { InitializeComponent(); } private void CloseButton_Click(object sender, EventArgs e) { Close(); } private void CalculateButton_Click(object sender, EventArgs e) { int DaysInteger, BeginningOdometerInteger, EndingOdometerInteger, CarSizeInteger, DiscountInteger; if (LicenseTextBox.Text != "") if (CompactRadioButton.Checked || MidSizeRadioButton.Checked || LuxuryRadioButton.Checked) { int.TryParse(DaysRentedTextBox.Text, out DaysInteger); int.TryParse(BeginningOdometerTextBox.Text, out BeginningOdometerInteger); if (BeginningOdometerInteger &gt; 0) { int.TryParse(EndingOdometerTextBox.Text, out EndingOdometerInteger); if (EndingOdometerInteger &gt; 0) { if (CompactRadioButton.Checked) CarSizeInteger = (int)CarSize.Compact; else if (MidSizeRadioButton.Checked) CarSizeInteger = (int)CarSize.MidSize; else CarSizeInteger = (int)CarSize.Luxury; } { if (CorporateRadioButton.Checked || InsuranceRadioButton.Checked) { if (CorporateRadioButton.Checked) DiscountInteger = (int)Discount.Corporate; else if (InsuranceRadioButton.Checked) DiscountInteger = (int)Discount.Insurance; //create an instance of the Corporate Class CorporateClass aCorpRental = new CorporateClass(BeginningOdometerInteger, EndingOdometerInteger, CarSizeInteger, DaysInteger, DiscountInteger); AmountDueTextBox.Text = (aCorpRental.getAmountDue()).ToString("C"); } else { //create an instance of the Rental Class RentalRate ARental = new RentalRate(BeginningOdometerInteger, EndingOdometerInteger, CarSizeInteger, DaysInteger); AmountDueTextBox.Text = (ARental.getAmountDue()).ToString("C"); } } } } } } private void DaysRentedTextBox_TextChanged(object sender, EventArgs e) { } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload