Validation Form [Praktikum ASP 4]

by - 3:43 PM

Di praktikum ASP 4 ini kita akan membahas tentang pembuatan form
dengan membuat tampilan seperti gambar disampaing ...



selanjutnya masukkan coding pada button Eksekusi ... 



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

        private void button1_Click(object sender, EventArgs e)
        {
            progressBar1.Value = 0;
            if (a.Text == "")
            {
                x1.SetError(a, "Masukkan Nama ");
            }
            else
            {
                x1.SetError(a, "");
            }

           if (b.Text == "")
            {
               x2.SetError (b, "Masukkan NIM ");
            }
            else
            {
                x2.SetError(b, "");
            }

            if (c.Text == "")
            {
                x3.SetError(c, "Masukkan Kelas ");
            }
            else
            {
                x3.SetError(c, "");
            }

            if (d.Text == "")
            {
                x4.SetError(d, "Masukkan SMP asal ");
            }
            else
            {
                x4.SetError(d, "");
            }
            for (int i = 0; i < progressBar1.Maximum; i++)
            {
                progressBar1.Value = progressBar1.Value + 1;
            }
            MessageBox.Show("\nNama\t : "+ a.Text + "\nNIM\t : " 
            + b.Text + "\nKelas\t :" + c.Text + "\nSMP asal\t : " + d.Text);
            }

        private void x(string p)
        {
            throw new NotImplementedException();
        }

}

Bila di RUN hasilnya akan tampak seperti gambar dibawah ...





You May Also Like

0 komentar