Public Class Form1
Dim st As String
Dim inz(0, 6) As String
Dim ii As Integer = 0
Dim jml As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
cek()
simpandata()
hitung()
tampilan()
bersih()
End Sub
Private Sub bersih()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox4.Text = ""
ComboBox1.Text = ""
RadioButton1.Checked = False
RadioButton2.Checked = False
End Sub
Private Function cek()
If RadioButton1.Checked = True Then
st = "Baru"
ElseIf RadioButton2.Checked = True Then
st = "Perpanjangan"
End If
Return st
End Function
Private Sub tampilan()
ListView1.Items.Add(TextBox1.Text)
ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(TextBox2.Text)
ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(ComboBox1.Text)
ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(TextBox4.Text)
ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(st)
ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(jml)
End Sub
Private Sub simpandata()
inz(ii, 0) = TextBox1.Text
inz(ii, 1) = TextBox2.Text
inz(ii, 2) = ComboBox1.Text
inz(ii, 3) = TextBox4.Text
inz(ii, 4) = st
inz(ii, 5) = jml
ii = ii + 1
ReDim inz(1, 6)
End Sub
Private Sub isicombo()
ComboBox1.Items.Add("Mobil")
ComboBox1.Items.Add("Sepeda Motor")
End Sub
Public Function hitung() As Integer
If st = "Baru" Then
jml = (CInt(TextBox4.Text) / 60) + ((CInt(TextBox4.Text) / 60) * 0.15)
ElseIf st = "Perpanjangan" Then
jml = (CInt(TextBox4.Text) / 60) + ((CInt(TextBox4.Text) / 60) * 0.1)
End If
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
isicombo()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Application.Exit()
End Sub
Private Sub TextBox2_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TextBox2.Validating
If TextBox2.Text = "" Then
ErrorProvider1.SetError(TextBox1, "Data Nama masih Kosong")
End If
End Sub
Private Sub ComboBox1_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ComboBox1.Validating
If TextBox1.Text = "" Then
ErrorProvider1.SetError(TextBox1, "Harap Memilih Jenis Asuransi")
End If
End Sub
Private Sub TextBox4_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TextBox4.Validating
If TextBox1.Text = "" Then
ErrorProvider1.SetError(TextBox1, "Harga Masih Kosong")
End If
End Sub
Private Sub Button1_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles Button1.Validating
If TextBox1.Text = "" Then
ErrorProvider1.SetError(TextBox1, "Tidak Boleh Kosong")
Else
ErrorProvider1.SetError(TextBox1, "")
End If
If IsNumeric(TextBox2.Text) = True Then
ErrorProvider1.SetError(TextBox2, "Harus Huruf")
Else
ErrorProvider1.SetError(TextBox2, "")
End If
If IsNumeric(TextBox4.Text) = True Then
ErrorProvider1.SetError(TextBox4, "Harus Angka")
Else
ErrorProvider1.SetError(TextBox4, "")
End If
If RadioButton1.Checked = False And RadioButton2.Checked = False Then
ErrorProvider1.SetError(RadioButton1, "Harus pilih salah satu")
Else
ErrorProvider1.SetError(RadioButton1, "")
End If
End Sub
End Class
No comments:
Post a Comment
Ada pertanyaan, keluhan, sanggahan, kritik, atau pesan-pesan lainnya, tinggalkan komentar Anda dibawah ini. Terima kasih