Caranya cukup sederhana Pertama soba buat dulu form nya seperti ini :
Sedangkan untuk properties nya sobat buat seperti ini :
Untuk source kode adalah seperti ini :
Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
Me.habsen.Enabled = False
Me.htugas.Enabled = False
Me.huts.Enabled = False
Me.huas.Enabled = False
Me.Tabsen.Focus()
End Sub
Private Sub Tabsen_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Tabsen.TextChanged
Me.habsen.Text = 0.1 * Val(Me.Tabsen.Text)
End Sub
Private Sub Ttugas_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Ttugas.TextChanged
Me.htugas.Text = 0.2 * Val(Me.Ttugas.Text)
End Sub
Private Sub Tuts_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Tuts.TextChanged
Me.huts.Text = 0.3 * Val(Me.Tuts.Text)
End Sub
Private Sub Tuas_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Tuas.TextChanged
Me.huas.Text = 0.4 * Val(Me.Tuas.Text)
End Sub
Private Sub Bhitung_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bhitung.Click
'source code untuk menghitung total nilai
Me.Ttotal.Text = Val(Me.habsen.Text) + Val(Me.htugas.Text) + Val(Me.huts.Text) + Val(Me.huas.Text)
'perintah percabangan untuk mengetahui hasil Grade
If Me.Ttotal.Text >= 80 And Me.Ttotal.Text <= 100 Then
Me.Tgrade.Text = "A"
ElseIf Me.Ttotal.Text >= 69 And Me.Ttotal.Text <= 79 Then
Me.Tgrade.Text = "B"
ElseIf Me.Ttotal.Text >= 56 And Me.Ttotal.Text <= 68 Then
Me.Tgrade.Text = "C"
ElseIf Me.Ttotal.Text >= 40 And Me.Ttotal.Text <= 55 Then
Me.Tgrade.Text = "D"
Else
Me.Tgrade.Text = "E"
End If
'source code untuk keterangan lulus
If Me.Tgrade.Text = "A" Or Me.Tgrade.Text = "B" Or Me.Tgrade.Text = "C" Then
Me.Tket.Text = "LULUS"
Else
Me.Tket.Text = "GAGAL"
End If
End Sub
Private Sub Bulang_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bulang.Click
Me.Tabsen.Text = ""
Me.Ttugas.Text = ""
Me.Tuts.Text = ""
Me.Tuas.Text = ""
Me.habsen.Text = ""
Me.htugas.Text = ""
Me.huts.Text = ""
Me.huas.Text = ""
Me.Ttotal.Text = ""
Me.Tgrade.Text = ""
Me.Tket.Text = ""
End Sub
Private Sub Bkeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bkeluar.Click
Dim p As String
p = MsgBox("Keluar Aplikasi??", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Keluar")
If p = vbYes Then
Me.Close()
End If
End Sub
Itulah contoh membuat percabangan if else dan else if menggunakan VB.Net semoga bermanfaat./** Informasi Komputer d **/var sitti_pub_id = "BC0012233";var sitti_ad_width = "336";var sitti_ad_height = "280";var sitti_ad_type = "2";var sitti_ad_number = "3";var sitti_ad_name = "Informasi Komputer d";var sitti_dep_id = "24892";
0 komentar:
Posting Komentar