Penerapan Komputer
Penerapan Komputer
Penerapan Komputer
Latihan 4
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
If TextBox1.Text = "cakra lagawa" And TextBox2.Text = "cahyadi gila" Then
MsgBox("anda berhasil login", vbOKOnly, "info")
Else
MsgBox("Anda kurang beruntung, coba lagi tahun depan!!", vbOKOnly, "peringatan!")
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button2.Click
Close()
End Sub
End Class
Latihan 5
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
Dim ANGKA As Integer
Dim hasil As String
Dim i As Byte
If ComboBox1.Text = "bilangan ganjil" Then
For i = 1 To Val(TextBox1.Text) Step 2
ANGKA = ANGKA + i
hasil = hasil & " " & i
Next
Label3.Text = hasil
TextBox2.Text = ANGKA
ElseIf ComboBox1.Text = "bilangan genap" Then
For i = 2 To Val(TextBox1.Text) Step 2
ANGKA = ANGKA + i
hasil = hasil & " " & i
Next
Label3.Text = hasil
TextBox2.Text = ANGKA
End Sub
Latihan 3
Public Class Form1
Dim angkapertama As Integer
Dim angkakedua As Integer
Dim Hitung As String
Dim Daftar As String
Dim Keluar As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
' membuat program hitung rata-rata
End Sub
Private Sub btnhitung_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
btnhitung.Click
'inisialisasikan tombol hitung
txthasil.Text = txthasil.Text & Hitung
End Sub
Private Sub btnkeluar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
btnkeluar.Click
txthasil.Text = txthasil.Text & Keluar
End Sub
Private Sub btndaftar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
btndaftar.Click
txthasil.Text = txthasil.Text & Daftar
MessageBox.Show("Silahkan kembali mengecek jawaban anda", vbOK, "Pesan")
End Sub
End Class