0% found this document useful (0 votes)
38 views4 pages

Kalkulator: Form1 Object Eventargs

The document contains code snippets from several Visual Basic .NET programs, including: 1. A basic calculator application that performs addition, subtraction, multiplication and division when buttons are clicked. 2. A Celsius to Fahrenheit converter that calculates Fahrenheit when a button is clicked. 3. A sales application that calculates subtotals, discounts and totals based on item selection and quantity.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views4 pages

Kalkulator: Form1 Object Eventargs

The document contains code snippets from several Visual Basic .NET programs, including: 1. A basic calculator application that performs addition, subtraction, multiplication and division when buttons are clicked. 2. A Celsius to Fahrenheit converter that calculates Fahrenheit when a button is clicked. 3. A sales application that calculates subtotals, discounts and totals based on item selection and quantity.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Kalkulator

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button1.Click
hasil.Text = Val(angka1.Text) + Val(angka2.Text)
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button2.Click
hasil.Text = Val(angka1.Text - angka2.Text)
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button3.Click
hasil.Text = Val(angka1.Text * angka2.Text)
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button4.Click
hasil.Text = Val(angka1.Text / angka2.Text)
End Sub
End Class

Suho

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles hitung.Click
fh.Text = (1.8 * celcius.Text) + 32

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button2.Click
Me.Close()
End Sub

Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button1.Click
celcius.Clear()
fh.Clear()
End Sub
End Class

Penjualan

Public Class Form1

Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Label4.Click

End Sub

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles cb.SelectedIndexChanged
If cb.Text = "001" Then
barang.Text = "Spidol"
harga.Text = 5000
ElseIf cb.Text = "002" Then
barang.Text = "buku"
harga.Text = 2000
ElseIf cb.Text = "003" Then
barang.Text = "pulpen"
harga.Text = 3000
ElseIf cb.Text = "004" Then
barang.Text = "pensil"
harga.Text = 1000
End If
End Sub

Private Sub kuantitas_TextChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles kuantitas.TextChanged
subtot.Text = Val(kuantitas.Text) * Val(harga.Text)
If Val(subtot.Text) <= 30000 Then
diskon.Text = 0
ElseIf Val(subtot.Text) >= 30000 Then
diskon.Text = 0.05 * Val(subtot.Text)
End If
grand.Text = Val(subtot.Text) - Val(diskon.Text)
End Sub

Private Sub bayar_TextChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles bayar.TextChanged

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button1.Click
cb.Text = ""
barang.Text = ""
harga.Text = ""
kuantitas.Text = ""
subtot.Text = ""
diskon.Text = ""
grand.Text = ""
bayar.Text = ""
balek.Text = ""
End Sub

Private Sub subtot_TextChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles subtot.TextChanged

End Sub

Private Sub hitung_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles hitung.Click
balek.Text = Val(bayar.Text) - Val(grand.Text)
End Sub
End Class

Penggajian

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button1.Click
pph.Text = gajipokok.Text * 0.05
totalgaji.Text = Val(gajipokok.Text) + Val(tjistri.Text) + Val(tjanak.Text)
gajibersih.Text = Val(totalgaji.Text) - Val(pph.Text)
End Sub

Private Sub status_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles status.SelectedIndexChanged
If status.Text = "menikah" Then
tjistri.Text = 250000
Else
tjistri.Text = 0
End If
End Sub

Private Sub jlhanak_TextChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles jlhanak.TextChanged
If jlhanak.Text <= 3 Then
tjanak.Text = jlhanak.Text * 200000
ElseIf jlhanak.Text > 3 Then
tjanak.Text = 600000
End If
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button2.Click
Me.Close()
End Sub
End Class

Dgv mahasiswa
Public Class Form1
Private Sub simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles simpan.Click
dgvmhs.rows.add()
Dim i As Integer
i = dgvmhs.RowCount - 2
dgvmhs.Rows(i).Cells(0).Value = nim.Text
dgvmhs.Rows(i).Cells(0).Value = nama.Text
dgvmhs.Rows(i).Cells(0).Value = jurusan.Text
dgvmhs.Rows(i).Cells(0).Value = kelas.Text
Call bersih()
End Sub
Sub bersih()
nim.Clear()
nama.Clear()
jurusan.Text = ""
kelas.Clear()
End Sub

Private Sub ubah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles ubah.Click
dgvmhs.CurrentRow.Cells(0).Value = nim.Text
dgvmhs.CurrentRow.Cells(1).Value = nama.Text
dgvmhs.CurrentRow.Cells(2).Value = jurusan.Text
dgvmhs.CurrentRow.Cells(3).Value = kelas.Text
Call bersih()
End Sub

Private Sub dgvmhs_CellContentClick(ByVal sender As System.Object, ByVal e As


System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvmhs.CellContentClick
nim.Text = dgvmhs.CurrentRow.Cells(0).Value
nama.Text = dgvmhs.CurrentRow.Cells(1).Value
jurusan.Text = dgvmhs.CurrentRow.Cells(2).Value
kelas.Text = dgvmhs.CurrentRow.Cells(3).Value
End Sub

Stopwatch
Public Class Form1
Dim angkajam, angkamenit, angkadetik, angkamilidetik As Integer
Dim J, M, D, MD As String
Sub jam()
If angkajam < 10 Then
J = "0" & CStr(angkajam)
Else
J = CStr(angkajam)
End If
End Sub
Sub menit()
If angkamenit = 60 Then
angkamenit = 0
angkajam += 1
End If
If angkamenit < 10 Then
M = "0" & CStr(angkamenit)
Else
M = CStr(angkamenit)
End If
End Sub
Sub detik()
If angkadetik = 60 Then
angkadetik = 0
angkamenit += 1
End If
If angkadetik < 10 Then
D = "0" & CStr(angkadetik)
Else
D = CStr(angkadetik)
End If
End Sub
Sub milidetik()
angkamilidetik += 1
If angkamilidetik = 100 Then
angkamilidetik = 0
angkadetik += 1
End If
If angkamilidetik < 10 Then
MD = "0" & CStr(angkamilidetik)
Else
MD = CStr(angkamilidetik)
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button2.Click
Timer1.Enabled = False
angkajam = 0
angkamenit = 0
angkadetik = 0
angkamilidetik = 0
Label1.Text = "00:00:00:00"
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button1.Click
Timer1.Enabled = True
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Timer1.Tick
Call jam()
Call menit()
Call detik()
Call milidetik()
Label1.Text = String.Format("{0}:{1}:{2}:{3}", J, M, D, MD)
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles MyBase.Load

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button3.Click
Timer1.Enabled = False
End Sub
End Class

You might also like