Saturday 10 November 2012

Source code keliling PP

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 Penghitung_Keliling_PP
{
    public partial class frmPenghitung : Form
    {
        public frmPenghitung()
        {
            InitializeComponent();
        }

        private void label3_Click(object sender, EventArgs e)
        {

        }

        private void cmdHitung_Click(object sender, EventArgs e)
        {
            if (txtPanjang.Text == "")
            {
                errorProvider1.SetError(txtPanjang, "isikan nilai panjang!");
                txtPanjang.Focus();
            }
            else if (txtLebar.Text == "")
            {
                errorProvider1.SetError(txtLebar, "isikan nilai lebar!");
                txtLebar.Focus();
            }
            else
            {
                txtKeliling.Text = (2 * (int.Parse(txtPanjang.Text) + int.Parse(txtLebar.Text))).ToString();

                txtPanjang.Clear();
                txtLebar.Clear();

            errorProvider1.SetError(txtPanjang, "");
            errorProvider1.SetError(txtLebar, "");
        }
    }

        private void txtKeliling_TextChanged(object sender, EventArgs e)
        {
            Console.Write(txtKeliling);
        }
    }
}

0 komentar:

Post a Comment

Note: only a member of this blog may post a comment.