nav#menunav { border-bottom: 1px solid #e8e8e8; }

Contoh Coding Tentang Penggunaan IF di Visual Basic

Image by GoodHead4Media from Pixabay


KASUS 1
Private Sub Command1_Click()
txtgapok.Text = "1500000"
If txtlembur.Text >= 48 Then
txtgajilembur.Text = (txtlembur.Text - 48) * 12000 + (48000)
Else
 txtgajilembur.Text = "0"
 End If
 If cmbstatus.Text = "sudah menikah" Then
txtistri.Text = 25000
Else
txtistri.Text = 0
txtanak.Text = 0
txtistri.Text = 0
txttanak.Text = 0
End If
If txtanak.Text <= 3 Then
txttanak.Text = txtanak.Text * 21000
Else
txttanak.Text = "63000"
End If
txtgaber.Text = Val(txtgapok.Text) + Val(txtgajilembur.Text) + Val(txtistri.Text) + Val(txttanak.Text)

End Sub

KASUS 2
Private Sub Command1_Click()
If tipe.Text = "ECO" Then
harga.Text = 800000
Else
harga.Text = 950000
End If

If usia.Text <= 40 Then
bonus.Text = "dapat"
Else
bonus.Text = "tidak dapat"
End If

If usia.Text < 10 Or usia.Text > 55 And pekerjaan.Text = "Pelajar" Then
diskon.Text = Val(harga.Text) * 0.1
ElseIf usia.Text >= 45 And pekerjaan.Text = "PNS" Then
diskon.Text = Val(harga.Text) * 0.12
End If
End Sub



Related Posts

0 Post a Comment