Friday, July 20, 2012

Contoh Pembuatan Program di Visual Basic

Ini salah satu contoh dari program di Visual Basic, Saya telah membuat sebuah contoh yang dapat mengetahui suatu barang dengan cara mengisi kode barangnya saja. Bila kode barangnya sudah di input (diisi) maka, akan tampil nama barang yang sesuai dengan kode barangnya dan sebuah harga dari barang tersebut. Setelah nama barang dan harganya terlihat, anda bisa menginput (memasukan) jumlah unit (barang) yang di beli. Selanjutnya anda bisa mengetahui jumlah harga setelah anda memasukan jumlah barang yang di beli. Anda juga dapat mengetahui berapa diskon yang di dapat dan jumlah dari harga sebenarnya. Anda dapat memasukan koding (kode) dari sebuah program tersebut, koding (kodenya) adalah, sebagai berikut :
Private Sub Command1_Click()
If Text1.Text = “CPU” Then
Text2.Text = “Central Processing Unit”
Text3.Text = “275000″
ElseIf Text1.Text = “RAM” Then
Text2.Text = “Random Access Memory”
Text3.Text = “225000″
ElseIf Text1.Text = “HDD” Then
Text2.Text = “Hard Disk”
Text3.Text = “425000″
ElseIf Text1.Text = “MTR” Then
Text2.Text = “Monitor”
Text3.Text = “750000″
ElseIf Text1.Text = “CDR” Then
Text2.Text = “Cd Room”
Text3.Text = “175000″
ElseIf Text1.Text = “PRT” Then
Text2.Text = “Printer”
Text3.Text = “500000″
End If
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Command4_Click()
Text7.Text = (Text3.Text) * (Text4.Text)
Text6.ForeColor = vbBlue
If Text7.Text >= 2000000 Then
Option1.Value = True
Option2.Value = False
Option3.Value = False
Option4.Value = False
Text5.Text = “20″
Text6.Text = (Text7.Text) – ((Text7.Text) * (Text5.Text) / 100)
ElseIf (Text7.Text < 2000000) And (Text7.Text > 1000000) Then
Option1.Value = False
Option2.Value = True
Option3.Value = False
Option4.Value = False
Text5.Text = “10″
Text6.Text = (Text7.Text) – ((Text7.Text) * (Text5.Text) / 100)
ElseIf (Text7.Text < 1000000) And (Text7.Text > 500000) Then
Option1.Value = False
Option2.Value = False
Option3.Value = True
Option4.Value = False
Text5.Text = “5″
Text6.Text = (Text7.Text) – ((Text7.Text) * (Text5.Text) / 100)
ElseIf Text7.Text < 500000 Then
Option1.Value = False
Option2.Value = False
Option3.Value = False
Option4.Value = True
Text5.Text = “0″
Text6.Text = Val(Text7.Text)
End If
End Sub
Private Sub Command5_Click()
Text1.Text = “”
Text2.Text = “”
Text3.Text = “”
End Sub
Private Sub Command6_Click()
Text4.Text = “”
Text7.Text = “”
End Sub
Private Sub Command7_Click()
Text1.Text = “”
Text2.Text = “”
Text3.Text = “”
Text4.Text = “”
Text5.Text = “”
Text6.Text = “”
Text7.Text = “”
Option1.Value = False
Option2.Value = False
Option3.Value = False
Option4.Value = False
End Sub
Karena contoh tersebut mempunyai lebih dari 2 pengulangan, maka saya menggunakan contoh dari pengulangan If .. Then .. Else ..
pengulangan tersebut bisa melakukan pengulangan lebih dari 2 pengulangan.
Akan tampil seperti gambar di bawah ini……





HOT INFO

Anda ingin mencari refrensi dan contoh program lengkap ? Kami ada. Sekarang Anda bisa mencari Tugas Visual Basic di situs ini : www.panduanSkripsi.net. Koleksi program lengkap di sana, proyek PHP dan MySQL, juga jQuery dan Framework. Bukunya juga ada.

No comments:

Post a Comment