" Umut, hiç görmeyen birine gökkuşağını anlatmak kadar zor ve imkansız... "

Categories

-

Vb.Net Kullanici Tanimli Fonksiyonlar !!!

Vb.Net kullanici tanimli fonksiyonlar örnegimizde gerekli fonksiyonlari kendimiz olusturarak, bilgileri kontroller yardimiyla girerek fonksiyonlarda gerekli islemler bittikten sonra tekrar bize göndermesi örnegi.

Kodlarimizi yaziyoruz;

Public Class Form1

Function cocuk_yardimi(ByVal m As Integer, ByVal c As Byte) As Double

If c = 0 Then

Return (m / 100)

ElseIf c = 1 Then

Return (2 * m / 100)

ElseIf c > 1 Then

Return (5 * m / 100)

Else : Return 0

End If

End Function


Function aile_yardimi(ByVal kod As Byte) As Integer

If kod = 1 Then

Return (22)

ElseIf kod = 0 Then

Return (48)

Else : Return 0

End If

End Function


Function yabanci_dil(ByVal kod As Byte) As Integer

If kod = 0 Then

Return 25

ElseIf kod = 1 Then

Return 55

ElseIf kod = 2 Then

Return 125

Else

Return 0

End If

End Function


Function kidem(ByVal m As Integer, ByVal kod As Byte) As Double

Return (kod * m / 100)

End Function

Sub doldur()

Button1.Enabled = False

ComboBox1.Enabled = False

ComboBox2.Enabled = False

ComboBox1.Text = "Birini Seçiniz"

ComboBox1.Items.Add("Aliyor")

ComboBox1.Items.Add("Almiyor")

ComboBox2.Text = "Birini Seçiniz"

ComboBox2.Items.Add("1 cocuk")

ComboBox2.Items.Add("2 cocuk")

ComboBox2.Items.Add("Daha fazla")

ComboBox3.Enabled = False

ComboBox3.Text = "Birini Seçiniz"

ComboBox3.Items.Add("70 ile 90 arasinda")

ComboBox3.Items.Add("80 ile 89 arasinda")

ComboBox3.Items.Add("90 ile 100 arasinda")

ComboBox4.Enabled = False

ComboBox4.Text = "Birini Seçiniz"

ComboBox4.Items.Add("IlkÖgretim Mezunu")

ComboBox4.Items.Add("Lise Mezunu")

ComboBox4.Items.Add("Üniversite Mezunu")

ComboBox4.Items.Add("Yüksek Lisans Mezunu")

ComboBox4.Items.Add("Doktora Mezunu")

End Sub


Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

doldur()

End Sub


Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

If TextBox1.Text = "" Then

ErrorProvider1.SetError(TextBox1, "Bos Geçilemez !!!")

Else

Dim maas As Integer = TextBox1.Text

If R_evli.Checked = True Then

Dim evli As Integer = 0

If ComboBox1.SelectedIndex = -1 Then

ErrorProvider1.SetError(ComboBox1, "")

Else

maas = maas + aile_yardimi(ComboBox1.SelectedIndex)

End If

ElseIf R_bekar.Checked = False Then

ComboBox1.Enabled = False

ComboBox2.Enabled = False

maas = maas + 0

End If

If ComboBox1.SelectedIndex = -1 Or ComboBox2.SelectedIndex = -1 Or ComboBox3.SelectedIndex = -1 Or ComboBox4.SelectedIndex = -1 Then

MsgBox("Gerekli alanlar bos geçilemez !!!", MsgBoxStyle.Information, "Kontrol")

Else

Dim cocuk_y As Integer = cocuk_yardimi(maas, ComboBox2.SelectedIndex)

Dim y_dil As Integer = yabanci_dil(ComboBox3.SelectedIndex)

Dim kidem_t As Integer = kidem(maas, ComboBox4.SelectedIndex)

maas = maas + cocuk_y + y_dil + kidem_t

MsgBox("Maas Tutariniz" + " " + Convert.ToString(maas) + " " + "TL", MsgBoxStyle.Information, "Maas Tutari")

End If

End If

End Sub


Private Sub R_evli_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles R_evli.CheckedChanged

ComboBox1.Enabled = True

ComboBox2.Enabled = True

ComboBox3.Enabled = True

ComboBox4.Enabled = True

Button1.Enabled = True

End Sub

Private Sub R_bekar_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles R_bekar.CheckedChanged

ComboBox1.Enabled = False

ComboBox2.Enabled = False

ComboBox3.Enabled = True

ComboBox4.Enabled = True

Button1.Enabled = True

End Sub

End Class

    

Örnek uygulamayi buradan indirebilirsiniz.

  • 0
  • 824
  • 0

- BUNLARIDA GÖZDEN GEÇİREBİLİRSİNİZ -

HENÜZ YORUM YAPILMAMIŞ !

Yorum yazın

HAKKIMDA

KONULARI TAKİP EDİN

SOSYAL AĞLAR

  • Mesajınızı Gonderin