Jumat, 20 Desember 2013

2nd Modifikasi aplikasi “Hello, World” dengan Visual Basic 6.0

2nd Hello World Modif VB6

Dikarenakan terlalu banyak menyita waktu dalam pembuatannya khususnya dalam menggunakan metode menambah kontrol secara dinamis pada saat aplikasi dijalankan, maka mulai dari postingan ini sampai yang berikutnya saya akan menggunakan metode standar. lagi pula maksud dan tujuan saya membuat blog ini diantaranya yaitu untuk membuat perbandingan pemrograman pada Visual Basic 6 dan Visual Basic.NET.

1. Jalankan aplikasi Visual Basic 6.0

2. Pada jendela “New Project” pilih “Standard EXE” kemudian tekan tombol “Open”

3. Berikut setingan kontrol properti yang terdapat pada aplikasi ini

Object Name Properties Setting
Form Form1 Border Style 1 - Fixed Single
    Caption Hello World
    Start Up Position 2 - Center Screen
Label lblName Auto size True
    Caption Type Your Name:
    Font Arial; 10pt
Text Box txtName Text (Empty)
    Font Arial; 12pt
Label lblShow Alignment 2 - Center
    Back Color &H00FFFFFF&
    Font Arial; 24pt
Command Button cmdClickHere Caption Click Here
    Font Arial; 10pt
Frame fraBackForm Caption Background (RGB)
High Scrolls Bar hsbRed Large Change 30
    Max 255
High Scrolls Bar hsbGreen Large Change 30
    Max 255
High Scrolls Bar hsbBlue Large Change 30
    Max 255
Command Button cmdExit Caption E&xit
    Font Arial; 10pt
Frame fraShowFont Caption Font Properties
    Font Arial; 10pt
Label lblFontAlignment Auto size True
    Caption Alignment:
    Font Arial; 10pt
Combo Box cmbAlignment Enabled

False

    Font Arial; 10pt
    List

Left Justify
Center
Right Justify

    Style 2 – Dropdown List
Frame fraFontColor Caption Color
    Font Arial; 10pt
Option Button optRed Caption Red
    Enabled

False

    Font Arial; 10pt
Option Button optGreen Caption Green
    Enabled

False

    Font Arial; 10pt
Option Button optBlue Caption Blue
    Enabled

False

    Font Arial; 10pt
Option Button optYellow Caption Yellow
    Enabled

False

    Font Arial; 10pt
Frame fraFontStyle Caption Style
    Font Arial; 10pt
Check Box chkBold Caption Bold
    Enabled

False

    Font Arial; 10pt
Check Box chkItalic Caption Italic
    Enabled

False

    Font Arial; 10pt
Check Box chkUnderline Caption Underline
    Enabled

False

    Font Arial; 10pt
Check Box chkStrikethru Caption Strikethrough
    Enabled

False

    Font Arial; 10pt

4. Berikut event code program

Private Sub chkBold_Click()
lblShow.FontBold = chkBold.Value
End Sub

Private Sub chkItalic_Click()
lblShow.FontItalic = chkItalic.Value
End Sub

Private Sub chkStrikethru_Click()
lblShow.FontStrikethru = chkStrikethru.Value
End Sub

Private Sub chkUnderline_Click()
lblShow.FontUnderline = chkUnderline.Value
End Sub

Private Sub cmbAlignment_Click()
Select Case cmbAlignment.ListIndex
Case 0
lblShow.Alignment = vbLeftJustify
Case 1
lblShow.Alignment = vbCenter
Case 2
lblShow.Alignment = vbRightJustify
End Select
End Sub

Private Sub cmdClickHere_Click()
If cmdClickHere.Caption = "Click Here" Then
lblShow.Caption = txtName.Text
txtName.Enabled = False
txtName.BackColor = &H8000000F
cmbAlignment.Enabled = True
chkBold.Enabled = True
chkItalic.Enabled = True
chkUnderline.Enabled = True
chkStrikethru.Enabled = True
optRed.Enabled = True
optGreen.Enabled = True
optBlue.Enabled = True
optYellow.Enabled = True
cmdClickHere.Caption = "New"
ElseIf cmdClickHere.Caption = "New" Then
txtName.Enabled = True
txtName.BackColor = &H80000005
cmbAlignment.Enabled = False
chkBold.Enabled = False
chkBold.Value = False
chkItalic.Enabled = False
chkItalic.Value = False
chkUnderline.Enabled = False
chkUnderline.Value = False
chkStrikethru.Enabled = False
chkStrikethru.Value = False
optRed.Enabled = False
optRed.Value = False
optGreen.Enabled = False
optGreen.Value = False
optBlue.Enabled = False
optBlue.Value = False
optYellow.Enabled = False
optYellow.Value = False
txtName.Text = ""
txtName.SetFocus
cmdClickHere.Caption = "Click Here"
lblShow.Caption = ""
End If
End Sub

Private Sub cmdExit_Click()
Dim Response As Integer

Response = MsgBox("Close the program", vbQuestion + vbYesNo, "Confirmation")

If Response = vbYes Then
End
End If
End Sub

Private Sub hsbBlue_Change()
Rubah_Warna
End Sub

Private Sub hsbGreen_Change()
Rubah_Warna
End Sub

Private Sub hsbRed_Change()
Rubah_Warna
End Sub

Private Sub Rubah_Warna()
Me.BackColor = RGB(hsbRed.Value, hsbGreen.Value, hsbBlue.Value)
lblName.BackColor = RGB(hsbRed.Value, hsbGreen.Value, hsbBlue.Value)
fraBackForm.BackColor = RGB(hsbRed.Value, hsbGreen.Value, hsbBlue.Value)
fraShowFont.BackColor = RGB(hsbRed.Value, hsbGreen.Value, hsbBlue.Value)
lblFontAlignment.BackColor = RGB(hsbRed.Value, hsbGreen.Value, hsbBlue.Value)
fraFontStyle.BackColor = RGB(hsbRed.Value, hsbGreen.Value, hsbBlue.Value)
chkBold.BackColor = RGB(hsbRed.Value, hsbGreen.Value, hsbBlue.Value)
chkItalic.BackColor = RGB(hsbRed.Value, hsbGreen.Value, hsbBlue.Value)
chkUnderline.BackColor = RGB(hsbRed.Value, hsbGreen.Value, hsbBlue.Value)
chkStrikethru.BackColor = RGB(hsbRed.Value, hsbGreen.Value, hsbBlue.Value)
fraFontColor.BackColor = RGB(hsbRed.Value, hsbGreen.Value, hsbBlue.Value)
optRed.BackColor = RGB(hsbRed.Value, hsbGreen.Value, hsbBlue.Value)
optGreen.BackColor = RGB(hsbRed.Value, hsbGreen.Value, hsbBlue.Value)
optBlue.BackColor = RGB(hsbRed.Value, hsbGreen.Value, hsbBlue.Value)
optYellow.BackColor = RGB(hsbRed.Value, hsbGreen.Value, hsbBlue.Value)
End Sub

Private Sub optBlue_Click()
lblShow.ForeColor = vbBlue
End Sub

Private Sub optGreen_Click()
lblShow.ForeColor = vbGreen
End Sub

Private Sub optRed_Click()
lblShow.ForeColor = vbRed
End Sub

Private Sub optYellow_Click()
lblShow.ForeColor = vbYellow
End Sub

Private Sub txtName_Change()
cmdClickHere.Enabled = True

If txtName.Text = "" Then
cmdClickHere.Enabled = False
End If
End Sub

Private Sub txtName_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then cmdClickHere_Click
End Sub



Label:

0 Komentar:

Posting Komentar

Berlangganan Posting Komentar [Atom]

<< Beranda