Function by Value in Visual Basic.Net

Function by Value in Visual basic.Net is one of the parameters like another parameter such as Function by reference. Well, in this case, Let's try to make function using by value parameter in visual basic.Net 2003. Well, actually Visual Basic.Net 2003 and Visual basic.Net 2005 is almost the same, Even my Book's write Visual Basic.Net and SQL Server 2005, Here we are :
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

Popular posts from this blog

Introduction to Use Case Diagram - Case study: Facebook

Kenapa tidak berkurban?

Sequential Search