Click here to Skip to main content
15,881,424 members
Home / Discussions / C#
   

C#

 
QuestionLinking forms Pin
Member 1524886721-Jun-21 12:15
Member 1524886721-Jun-21 12:15 
AnswerRe: Linking forms Pin
Richard Andrew x6421-Jun-21 13:22
professionalRichard Andrew x6421-Jun-21 13:22 
GeneralRe: Linking forms Pin
Member 1524886721-Jun-21 13:31
Member 1524886721-Jun-21 13:31 
GeneralRe: Linking forms Pin
Richard Andrew x6421-Jun-21 13:43
professionalRichard Andrew x6421-Jun-21 13:43 
GeneralRe: Linking forms Pin
Member 1524886721-Jun-21 15:23
Member 1524886721-Jun-21 15:23 
AnswerRe: Linking forms Pin
Gerry Schmitz22-Jun-21 6:32
mveGerry Schmitz22-Jun-21 6:32 
GeneralRe: Linking forms Pin
Member 1524886723-Jun-21 5:14
Member 1524886723-Jun-21 5:14 
QuestionNeed help with straight line depreciation coding Pin
Member 1524886721-Jun-21 8:38
Member 1524886721-Jun-21 8:38 
Hey guys,

As a beginner I'm going through exercises to try an learn the basics of C#. This exercise calls for a straightline depreciation to be calculated with user entering inputs for present value, salvage value, and years of depreciation. I'm stuck at this point and don't know how I should proceed -- if anyone can review and provide me with some direction it would be appreciated!

<
namespace StraightlineDepreciationCalculator
{
    public partial class frmStraightlinedDepreciationCalculator : Form
    {
        public frmStraightlinedDepreciationCalculator()
        {
            InitializeComponent();
        }

        private void btnClear_Click(object sender, EventArgs e)
        {
            // Clears text boxes and selects first tab in form
            txtPresentValue.Text = "";
            txtSalvageValue.Text = "";
            txtYearsOfDepreciation.Text = "";
            txtDisplay.Text = "";
            txtPresentValue.SelectAll();
            txtPresentValue.Select();

        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            // This function confirms and exits the application
            DialogResult dlgresult;
            dlgresult = MessageBox.Show("Do you want to exit the application?", "Close the form", MessageBoxButtons.YesNo);
            if (dlgresult == DialogResult.Yes)
            {
                //Closes the application
                System.Environment.Exit(1);
            }
            else
            {
                txtPresentValue.Select();
            }
        }

        private void btnCalculate_Click(object sender, EventArgs e)
        {
            // Validates user inputted data and calculates the value at the end of each year
            // displayed in multiline textbox
            double dblPresentValue = 0;
            double dblSalvageValue = 0;
            int intYearsOfDepreciation = 0;
            int intCounter = 0;
            string strDisplay = "";

            // Clear any text already in display
            txtDisplay.Text = "";

            // Get values from text boxes
            dblPresentValue = Convert.ToDouble(txtPresentValue.Text);
            dblSalvageValue = Convert.ToDouble(txtSalvageValue.Text);
            intYearsOfDepreciation = Convert.ToInt32(txtYearsOfDepreciation.Text);

            // Validate user entry
            if (dblPresentValue < 1 | dblPresentValue > 1000000)
            {
                MessageBox.Show("Present value must be between $1 and $1,000,000");
                txtPresentValue.Select(); //selects defective input text box
                txtPresentValue.SelectAll();
            }
            else if (dblSalvageValue > dblPresentValue)
            {
                MessageBox.Show("Salvage value cannot be greater than Present Value");
                txtSalvageValue.Select(); //selects defective input text box
                txtSalvageValue.SelectAll();
            }
            else if (intYearsOfDepreciation < 0 | intYearsOfDepreciation > 25)
            {
                MessageBox.Show("Years of Depreciation must be in 1 - 25 range");
                txtYearsOfDepreciation.Select(); //selects defective input text box
                txtYearsOfDepreciation.SelectAll();
            }
            else
            {
                // set up column headers in text display
                strDisplay = "Year      Asset Value/r/n-------      ---------------";

            }
                

        }
    }
}

AnswerRe: Need help with straight line depreciation coding Pin
OriginalGriff21-Jun-21 9:21
mveOriginalGriff21-Jun-21 9:21 
GeneralRe: Need help with straight line depreciation coding Pin
Member 1524886721-Jun-21 9:24
Member 1524886721-Jun-21 9:24 
GeneralRe: Need help with straight line depreciation coding Pin
OriginalGriff21-Jun-21 9:58
mveOriginalGriff21-Jun-21 9:58 
GeneralRe: Need help with straight line depreciation coding Pin
Member 1524886721-Jun-21 10:54
Member 1524886721-Jun-21 10:54 
GeneralRe: Need help with straight line depreciation coding Pin
Mycroft Holmes21-Jun-21 13:53
professionalMycroft Holmes21-Jun-21 13:53 
AnswerRe: Need help with straight line depreciation coding Pin
Gerry Schmitz22-Jun-21 6:27
mveGerry Schmitz22-Jun-21 6:27 
Questionc# language feature surprise using Linq ThenBy (observation) Pin
BillWoodruff20-Jun-21 23:40
professionalBillWoodruff20-Jun-21 23:40 
AnswerRe: c# language feature surprise using Linq ThenBy (observation) Pin
Richard Deeming21-Jun-21 1:29
mveRichard Deeming21-Jun-21 1:29 
GeneralRe: c# language feature surprise using Linq ThenBy (observation) Pin
BillWoodruff21-Jun-21 2:38
professionalBillWoodruff21-Jun-21 2:38 
Questioncan any one please explain how to connect to stratum 1 or 2 mining pool? Pin
Member 1336047319-Jun-21 7:11
Member 1336047319-Jun-21 7:11 
AnswerRe: can any one please explain how to connect to stratum 1 or 2 mining pool? Pin
OriginalGriff19-Jun-21 9:12
mveOriginalGriff19-Jun-21 9:12 
AnswerRe: can any one please explain how to connect to stratum 1 or 2 mining pool? Pin
BillWoodruff20-Jun-21 23:29
professionalBillWoodruff20-Jun-21 23:29 
QuestionPrinte page limit Pin
Member 1419221619-Jun-21 5:46
Member 1419221619-Jun-21 5:46 
QuestionDelegates, generic collection Pin
Samkelo3418-Jun-21 11:41
Samkelo3418-Jun-21 11:41 
AnswerRe: Delegates, generic collection Pin
OriginalGriff18-Jun-21 11:42
mveOriginalGriff18-Jun-21 11:42 
AnswerRe: Delegates, generic collection Pin
Mycroft Holmes18-Jun-21 12:39
professionalMycroft Holmes18-Jun-21 12:39 
JokeRe: Delegates, generic collection Pin
Peter_in_278018-Jun-21 15:03
professionalPeter_in_278018-Jun-21 15:03 

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.