Diberdayakan oleh Blogger.

MY LOVE, MY DREAM, MY PASSION

RSS

Pemrograman Komputer : Program Radio Button


(name)
Radio button sangat setuju = rbSS
Radio button  setuju = rbS
Radio button kurang setuju = rbKS
Radio button tidak setuju = rbTS
Textbox1 = pilihan
Koding
public partial class Form1 : Form
    {
        int skor = 0;

        public Form1()
        {
            InitializeComponent();
        }

        private void pilihan_TextChanged(object sender, EventArgs e)
        {
     
        }

        private void rbSS_CheckedChanged(object sender, EventArgs e)
        {  
           
            RadioButton rbAktif = sender as RadioButton;
            if(rbAktif==rbSS)
                skor=4;

            pilihan.Text = skor.ToString();
        }

        private void rbS_CheckedChanged(object sender, EventArgs e)
        {
           

            RadioButton rbAktif = sender as RadioButton;
            if (rbAktif == rbS)
                skor = 3;

            pilihan.Text = skor.ToString();
        }

        private void rbKS_CheckedChanged(object sender, EventArgs e)
        {
           

            RadioButton rbAktif = sender as RadioButton;
            if (rbAktif == rbKS)
                skor = 2;

            pilihan.Text = skor.ToString();
        }

        private void rbTS_CheckedChanged(object sender, EventArgs e)
        {
           

            RadioButton rbAktif = sender as RadioButton;
            if (rbAktif == rbTS)
                skor = 1;

            pilihan.Text = skor.ToString();
        }
    }

}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Project_Radio_Buton
{
    public partial class Form1 : Form
    {
        int skor = 0;
        int skor1 = 0;
       

        public Form1()
        {
            InitializeComponent();
        }

        private void pilihan_TextChanged(object sender, EventArgs e)
        {
     
        }

        private void rbSS_CheckedChanged(object sender, EventArgs e)
        {  
           
            RadioButton rbAktif = sender as RadioButton;
            if(rbAktif==rbSS)
                skor=4;

            pilihan.Text = skor.ToString();

            total.Text = (skor + skor1).ToString();
           
        }

        private void rbS_CheckedChanged(object sender, EventArgs e)
        {
           

            RadioButton rbAktif = sender as RadioButton;
            if (rbAktif == rbS)
                skor = 3;

            pilihan.Text = skor.ToString();

            total.Text = (skor + skor1).ToString();
        }

        private void rbKS_CheckedChanged(object sender, EventArgs e)
        {
           

            RadioButton rbAktif = sender as RadioButton;
            if (rbAktif == rbKS)
                skor = 2;

            pilihan.Text = skor.ToString();

            total.Text = (skor + skor1).ToString();
        }

        private void rbTS_CheckedChanged(object sender, EventArgs e)
        {
           

            RadioButton rbAktif = sender as RadioButton;
            if (rbAktif == rbTS)
                skor = 1;

            pilihan.Text = skor.ToString();

            total.Text = (skor + skor1).ToString();
        }

        private void groupBox1_Enter(object sender, EventArgs e)
        {

        }

        private void rbSS2_CheckedChanged(object sender, EventArgs e)
        {
            RadioButton rbAktif = sender as RadioButton;
            if (rbAktif == rbSS2)
                skor1 = 4;

            pilihan2.Text = skor1.ToString();

            total.Text = (skor + skor1).ToString();
        }

        private void rbS2_CheckedChanged(object sender, EventArgs e)
        {
            RadioButton rbAktif = sender as RadioButton;
            if (rbAktif == rbS2)
                skor1 = 3;

            pilihan2.Text = skor1.ToString();

            total.Text = (skor + skor1).ToString();
        }

        private void rbKS2_CheckedChanged(object sender, EventArgs e)
        {
            RadioButton rbAktif = sender as RadioButton;
            if (rbAktif == rbKS2)
                skor1 = 2;

            pilihan2.Text = skor1.ToString();

            total.Text = (skor + skor1).ToString();
        }

        private void rbTS2_CheckedChanged(object sender, EventArgs e)
        {
            RadioButton rbAktif = sender as RadioButton;
            if (rbAktif == rbTS2)
                skor1 = 1;

            pilihan2.Text = skor1.ToString();

            total.Text = (skor + skor1).ToString();
        }

        private void total_TextChanged(object sender, EventArgs e)
        {
          
        }
    }

}

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

Pemrograman Komputer C# : Program Switch

{
            string Negara = "", ibukota = "";
            int Pilihan;
            Pilihan = int.Parse(Nomor.Text);
            switch(Pilihan)
            {
                case 1:
                    Negara="Indonesia";
                    ibukota="Jakarta";
                    break;
                case 2:
                    Negara="Jepang";
                    ibukota="Tokyo";
                    break;
                case 3:
                    Negara="Amerika";
                    ibukota="Washington DC";
                    break;
                case 4:
                    Negara="Inggris";
                    ibukota="London";
                    break;
            }
            if(Pilihan<1||Pilihan>4)
            {
                    Negara="tersebut";
                    ibukota = "tidak ada";
            }
       
            Hasil.Text = "Negara " +Negara+ " ibukota " +ibukota;
        }

    }

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS