Function by Value in Visual Basic.Net

1. Design the form like in the picture above
2. Don't forget, to setting the properties, like text1 named tktKode
3. type the source code bellow :
Private Sub btnHitung_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHitung.Click
Dim jml_biaya As Integer
jml_biaya = hitung_biaya(CInt(txtPemeriksaan.Text), CInt(txtObat.Text), cmbKelompok.SelectedIndex)
txtTotal.Text = jml_biaya
End Sub
Function hitung_biaya(ByVal pemeriksaan As Integer, ByVal obat As Integer, ByVal kelompok As Byte) As Integer
Dim potongan As Integer
Dim total As Integer
total = pemeriksaan + obat
Select Case kelompok
Case Is = 0
potongan = 0
Case Is = 1
potongan = (50 * total) / 100
Case Is = 2
potongan = (100 * total) / 100
End Select
hitung_biaya = total - potongan
End Function
Private Sub btnBaru_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBaru.Click
txtKode.Text = ""
txtNama.Text = ""
txtPemeriksaan.Text = ""
txtObat.Text = ""
cmbKelompok.Text = ""
txtKode.Focus()
End Sub
Private Sub btnKeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnKeluar.Click
End
End Sub
Well, have fun and try it ^-^.
Created By Ader
2. Don't forget, to setting the properties, like text1 named tktKode
3. type the source code bellow :
Private Sub btnHitung_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHitung.Click
Dim jml_biaya As Integer
jml_biaya = hitung_biaya(CInt(txtPemeriksaan.Text), CInt(txtObat.Text), cmbKelompok.SelectedIndex)
txtTotal.Text = jml_biaya
End Sub
Function hitung_biaya(ByVal pemeriksaan As Integer, ByVal obat As Integer, ByVal kelompok As Byte) As Integer
Dim potongan As Integer
Dim total As Integer
total = pemeriksaan + obat
Select Case kelompok
Case Is = 0
potongan = 0
Case Is = 1
potongan = (50 * total) / 100
Case Is = 2
potongan = (100 * total) / 100
End Select
hitung_biaya = total - potongan
End Function
Private Sub btnBaru_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBaru.Click
txtKode.Text = ""
txtNama.Text = ""
txtPemeriksaan.Text = ""
txtObat.Text = ""
cmbKelompok.Text = ""
txtKode.Focus()
End Sub
Private Sub btnKeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnKeluar.Click
End
End Sub
Well, have fun and try it ^-^.
Created By Ader