(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)
{
}
}
}