Saturday, May 19, 2018

VB. Net - Coding Membuat Latihan Operator Matematika


PublicClass FrmPert2

PrivateSub bttmod_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttmod.Click
        TextBox3.Text = Val(TextBox1.Text) Mod Val(TextBox2.Text)
EndSub

PrivateSub lblhasil_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblhasil.Click
EndSub

PrivateSub btttambah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btttambah.Click
        TextBox3.Text = Val(TextBox1.Text) + Val(TextBox2.Text)
EndSub

PrivateSub bttkurang_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttkurang.Click
        TextBox3.Text = Val(TextBox1.Text) - Val(TextBox2.Text)
EndSub

PrivateSub bttkali_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttkali.Click
        TextBox3.Text = Val(TextBox1.Text) * Val(TextBox2.Text)
EndSub

PrivateSub bttbagi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttbagi.Click
        TextBox3.Text = Val(TextBox1.Text) / Val(TextBox2.Text)
EndSub

PrivateSub keluar1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles keluar1.Click
End
EndSub

PrivateSub bttkurangdari_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttkurangdari.Click
If TextBox3.Text < TextBox1.Text Then
            TextBox3.Text = "Benar"
Else
            TextBox3.Text = "Salah"
EndIf
EndSub

PrivateSub bttsd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttsd.Click
If TextBox3.Text = TextBox1.Text Then
            TextBox3.Text = "Benar"
Else
            TextBox3.Text = "Salah"
EndIf
EndSub

PrivateSub bttlebih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttlebih.Click
If TextBox3.Text > TextBox1.Text Then
            TextBox3.Text = "Benar"
Else
            TextBox3.Text = "Salah"
EndIf
EndSub

PrivateSub kurangsd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kurangsd.Click
If TextBox3.Text <= TextBox1.Text Then
            TextBox3.Text = "Benar"
Else
            TextBox3.Text = "Salah"
EndIf
EndSub

PrivateSub kuranglebih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kuranglebih.Click
If TextBox3.Text <> TextBox1.Text Then
            TextBox3.Text = "Benar"
Else
            TextBox3.Text = "Salah"
EndIf
EndSub

PrivateSub bttlebihsd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttlebihsd.Click
If TextBox3.Text >= TextBox1.Text Then
            TextBox3.Text = "Benar"
Else
            TextBox3.Text = "Salah"
EndIf
EndSub

PrivateSub bersih1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bersih1.Click
        TextBox1.Text = " "
        TextBox2.Text = " "
        TextBox3.Text = " "
EndSub

PrivateSub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

EndSub

PrivateSub TextBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If e.KeyChar = Chr(13) Then
            TextBox2.Focus()
EndIf
EndSub
EndClass

Hasil Program
Contoh:
5 < 7 = Benar
Comments
0 Comments

No comments:

Post a Comment

Super Kawaii Cute Cat Kaoani