web stats

Kamis, 14 Agustus 2014

Word Editing (Semi-Intermediate) - Visual Basic

Program peningkatan dari Word Editing (Basic) yang dikembangkan dengan penggantian penggunaan komponen Tools Box. Komponen yang digunakan berupa Text Box, Option Button, Check Box, Frame, dan Command Button.
Buka program VB, kemudian buat tampilan form dan properties seperti gambar.
Setelah itu, ketikkan kode berikut dalam kode editor.

Private Sub Check1_Click()
If Check1.Value = 1 Then
Text1.FontBold = True
ElseIf Check1.Value = 0 Then
Text1.FontBold = False
End If
End Sub


Private Sub Check2_Click()
If Check2.Value = 1 Then
Text1.FontItalic = True
ElseIf Check2.Value = 0 Then
Text1.FontItalic = False
End If
End Sub

Private Sub Check3_Click()
If Check3.Value = 1 Then
Text1.FontUnderline = True
ElseIf Check3.Value = 0 Then
Text1.FontUnderline = False
End If
End Sub

Private Sub Check4_Click()
If Check4.Value = 1 Then
Text1.FontSize = 12
ElseIf Check4.Value = 0 Then
Text1.FontSize = 24
End If
End Sub

Private Sub Check5_Click()
If Check5.Value = 1 Then
Text1.FontSize = 35
ElseIf Check5.Value = 0 Then
Text1.FontSize = 25
End If
End Sub

Private Sub Check6_Click()
If Check6.Value = 1 Then
Text1.Visible = False
ElseIf Check6.Value = 0 Then
Text1.Visible = True
End If
End Sub

Private Sub Check7_Click()
If Check7.Value = 1 Then
Text1.FontStrikethru = True
ElseIf Check7.Value = 0 Then
Text1.FontStrikethru = False
End If
End Sub

Private Sub Check8_Click()
If Check8.Value = 1 Then
Text1.Font = "Cambria"
ElseIf Check8.Value = 0 Then
Text1.Font = "MS Sans Serif"
End If
End Sub

Private Sub Check9_Click()
If Check9.Value = 1 Then
Text1.Text = "BASIC VISUAL"
ElseIf Check9.Value = 0 Then
Text1.Text = "VISUAL BASIC"
End If
End Sub

Private Sub Option1_Click()
If Option1.Value = True Then
Text1.ForeColor = vbRed
Else
Text1.ForeColor = vbBlack
End If
End Sub

Private Sub Option2_Click()
If Option2.Value = True Then
Text1.ForeColor = vbBlue
End If
End Sub

Private Sub Option3_Click()
If Option3.Value = True Then
Text1.ForeColor = vbYellow
End If
End Sub

Private Sub Option4_Click()
If Option4.Value = True Then
Text1.ForeColor = &HC000C0
End If
End Sub

Private Sub Option5_Click()
If Option5.Value = True Then
Text1.ForeColor = &H80FF&
End If
End Sub

Private Sub Option6_Click()
If Option6.Value = True Then
Text1.ForeColor = vbBlack
End If
End Sub

Private Sub Option7_Click()
If Option7.Value = True Then
Text1.BackColor = vbRed
End If
End Sub

Private Sub Option8_Click()
If Option8.Value = True Then
Text1.BackColor = vbBlue
End If
End Sub

Private Sub Option9_Click()
If Option9.Value = True Then
Text1.BackColor = vbYellow
End If
End Sub


Private Sub Option10_Click()
If Option10.Value = True Then
Text1.BackColor = &HC000C0
End If
End Sub

Private Sub Option11_Click()
If Option11.Value = True Then
Text1.BackColor = &H80FF&
End If
End Sub

Private Sub Option12_Click()
If Option12.Value = True Then
Text1.BackColor = vbBlack
End If
End Sub


Private Sub Command1_Click()
Check1.Value = 0
Check2.Value = 0
Check3.Value = 0
Check4.Value = 0
Check5.Value = 0
Check6.Value = 0
Check7.Value = 0
Check8.Value = 0
Check9.Value = 0
Text1.ForeColor = vbBlack
Text1.BackColor = vbWhite
Text1.FontBold = False
Text1.FontItalic = False
Text1.FontUnderline = False
Text1.FontSize = 24
Text1.Visible = True
Text1.FontStrikethru = False
Text1.FontName = "MS Sans Serif"
Text1.Text = "VISUAL BASIC"
End Sub
 

Private Sub Command2_Click()
End
End Sub


Kemudian, jalankan program dengan menekan tombol "Start" di toolbar sehingga muncul tampilan seperti ini.
Tampilan program eksekusi setelah memilih Blue (FC), Yellow (BC), dan mencentang Bold, Underline, dan Strikethru
Tampilan program eksekusi setelah menekan tombol REFRESH (kembali seperti sediakala)
OK! Program telah berhasil dirancang!
Jika ada permasalahan, silahkan komentarnya dibawah...

Tidak ada komentar:

Posting Komentar