Selasa, 27 September 2011

 Perhitungan Nilai Mahasiswa

1.Mendesign pada Form seperti gambar di bawah ini
Properties

Objeck
Properti
Setting
Form

Name
Caption
Width
Heigth
FrmLat2
Perhitungan Nilai Mahasiswa
5000
3500
Label1
Caption
NPM
Label2
Caption
Nama Mahasiswa
Label3
Caption
Mata Kuliah
Label4
Caption
Nilai Mid
Label5
Caption
Nilai Semester
Label6
Caption
Nilai Kehadiran
Label7
Caption
Nilai Tugas
Label8
Caption
Total Nilai
Text1
Name
npm
Text2
Name
nama
Text3
Name
mk
Text4
Name
nmid
Text5
Name
ns
Text6
Name
nk
Text7
name
nt
Text8
name
total
Command1
Name
Caption
Cmdhitung
&Hitung
Command2
Name
Caption
Cmdhapus
&Hapus
Command3
Name
Caption
Cmdselesai
&Selesai

Double Click Form anda dan isikan kode program  di bawah ini

Sub hapus()
    npm.Text = ""
    nama.Text = ""
    mk.Text = ""
    nmid.Text = ""
    ns.Text = ""
    nk.Text = ""
    nt.Text = ""
    total.Text = ""
end sub

Private Sub Cmdhapus_Click()
                Hapus
                npm.setFocus
End Sub

Private Sub Cmdhitung_Click()
    total= 0.1 * nk.Text + 0.15 * nt.Text + 0.3 * nmid.Text + 0.45 * ns.Text
End Sub

Private Sub Cmdselesai_Click()
    Unload Me
End Sub

Private Sub Form_Load()
    hapus
End Sub

Menjalankan program Tekan F5

   


Menghitung  Volume Kubus dengan Menggunakan Visual basic  6.0

1.Aktifkan VB 6.0 melalui tombol Start→Program→Microsof Visual  Studio 6.0→ Microsof Visual  Basic 6.0  untuk membuka aplikasi Visual Basic 6.0 seperti tampilandi bawah ini
2.Akan muncul Tampilan seperti  beikut:
  Click Open.
3.Maka Akan Tampil gambar seperi di bawah ini
4.Selanjutnya Mendesign Prorgam Seperti gambar berikut

Propertis


Objeck
Properti
Setting
Form

Name
Caption
FrmLat1
Menghitung Volume Kubus
Label1
Caption
SISI
Label2
Caption
VOLUME
Text1
Name
sisi
Text2
Name
volume
Command1
Name
Caption
Cmdhitung
&Hitung
Command2
Name
Caption
Cmdhapus
&Hapus
Command3
Name
Caption
Cmdkeluar
&Keluar



Jika anda ingin mewarnai Form atau merubah bentuk tulisan, rubah di propertiesnya
Back  color  →Fungsinya Untuk mewarnai tampilan

Fore color → Fungsinya Untuk mewarnai tulisan

Font → Fungsinya Untuk merubah jenis dan ukuran tulisan


Double Click Form anda  ketikkan program di bawah ini
Sub hapus()
    sisi.Text = ""

    volume.Text = ""

End Sub

Private Sub Cmdhitung_Click()

volume = sisi * sisi * sisi

End Sub


Private Sub Cmdhapus_Click()

    hapus

End Sub


Jalankan programnya tekan  F5


selanjutnya Tambahkan kode program yang di atas seperti berikut


Private Sub Cmdhitung_Click()

    If sisi.Text = "" And volume.Text = "" Then

        MsgBox "sisi dan volume belum di isi..!" (Menampilkan pesan jika “sisi.text And volume.text “belum di isi)

        sisi.SetFocus ( Posisi kursor Anda focus pada” sisi”)

 Exit Sub

        Else

    If volume.Text = "" Then

        MsgBox "volume belum di isi..!" (Menampilkan pesan jika” volume belum di isi”)

        volume.SetFocus

    Exit Sub

    Else

    volume =sisi * sisi * sisi

    End If

    End If

End Sub



Private Sub cmdkeluar_Click()

    Dim pesan As String

    pesan = MsgBox("Anda yakin keluar..?", vbQuestion + vbYesNo)

    If pesan = vbYes Then

     Unload Me

     End If

End Sub



Private Sub Form_Load()

    hapus

end Sub


Private Sub sisi_ KeyPress(KeyAscii As Integer)                               
    If KeyAscii = 13 Then
    volume.SetFocus
    End If
End Sub

Private Sub vol_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
    Cmdhitung.SetFocus
    End If
End Sub