Setelah berlatih meng-inputkan dan mengeluarkan inputan, sekarang kita berlatih mengubah warna form dan memberi efek pada huruf (Bold & Italic). Berikut resepnya.
Buatlah sebuah Project dan tambahkan sebuah label, sebuah frame, 3 buah checkbox, 5 buah option box (di dalam frame) dan 3 buah command button kemudian masukkan kode berikut ini pada jendela Code (F7). File latihan dapat di download disini.
Private Sub biasa_Click()
Check2.Value = 0
Check1.Value = 0
Check3.Value = 1
Label1.FontBold = False
Label1.FontItalic = False
End Sub
Private Sub biru_Click()
Me.BackColor = vbBlue
End Sub
Private Sub bold_Click()
If Check1.Value = 1 And Label1.FontBold = True Then
Check1.Value = 0
Check3.Value = 0
Label1.FontBold = False
ElseIf Check1.Value = 0 And Label1.FontBold = False Then
Check1.Value = 1
Check3.Value = 0
Label1.FontBold = True
End If
End Sub
Private Sub hijau_Click()
Me.BackColor = vbGreen
End Sub
Private Sub hitam_Click()
Me.BackColor = vbBlack
End Sub
Private Sub italic_Click()
If Check2.Value = 1 And Label1.FontItalic = True Then
Check2.Value = 0
Check3.Value = 0
Label1.FontItalic = False
ElseIf Check2.Value = 0 And Label1.FontItalic = False Then
Check2.Value = 1
Check3.Value = 0
Label1.FontItalic = True
End If
End Sub
Private Sub kuning_Click()
Me.BackColor = vbYellow
End Sub
Private Sub merah_Click()
Me.BackColor = vbRed
End Sub
Property kontrol
No Obyek Properti Nilai
1 Command1 Caption &Bold
Font Bold
2 Command2 Caption &Italic
Font Italic
3 Command3 Caption B&iasa
4 Label1 Caption vbdesktop.blogspot.com
BackColor &H00FFFFFF&
BorderStyle 1-Fixed Single
5 Check1 Caption Bold
Font Bold
Enabled False
6 Check2 Caption Italic
Font Italic
Enabled False
7 Check3 Caption Biasa
Enabled False
8 Option1 (Name) merah
Caption Merah
9 Option2 (Name) kuning
Caption Kuning
10 Option3 (Name) hijau
Caption Hijau
11 Option4 (Name) biru
Caption Biru
12 Option5 (Name) hitam
Caption Hitam
Tampilkan postingan dengan label latihan vb. Tampilkan semua postingan
Tampilkan postingan dengan label latihan vb. Tampilkan semua postingan
vbdesktop - Input Output Teks
Setelah memahami dan mempraktekkan tentang 3 bab yang terdahulu (penulisan program, kontrol program, perulangan) sekarang saatnya kita belajar meng-inputkan sesuatu dan melihat hasilnya (output). Berikut resepnya.
Buatlah sebuah Project dan tambahkan 2 textbox, sebuah frame dan 4 buah label (2 di dalam frame) serta 2 buah command button kemudian masukkan kode berikut ini pada jendela Code (F7). File latihan dapat di download disini.
Private Sub Command1_Click()
Label3.Caption = Text1.Text
Label4.Caption = Text2.Text
End Sub
Private Sub Command2_Click()
Label3.Caption = ""
Label4.Caption = ""
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
End Sub
Property kontrol
No | Obyek | Properti | Nilai
1 |Command1 | Caption | &Tampilkan
2 |Command2 | Caption |&Ulangi
3 |Label3 | Caption |
4 |Label4 | Caption |
5 |Text1 | Text | [kosongi bagian ini]
6 |Text2 | Text | [kosongi bagian ini]
Buatlah sebuah Project dan tambahkan 2 textbox, sebuah frame dan 4 buah label (2 di dalam frame) serta 2 buah command button kemudian masukkan kode berikut ini pada jendela Code (F7). File latihan dapat di download disini.
Private Sub Command1_Click()
Label3.Caption = Text1.Text
Label4.Caption = Text2.Text
End Sub
Private Sub Command2_Click()
Label3.Caption = "
Label4.Caption = "
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
End Sub
Property kontrol
No | Obyek | Properti | Nilai
1 |Command1 | Caption | &Tampilkan
2 |Command2 | Caption |&Ulangi
3 |Label3 | Caption |
4 |Label4 | Caption |
5 |Text1 | Text | [kosongi bagian ini]
6 |Text2 | Text | [kosongi bagian ini]
Langganan:
Postingan (Atom)