SLIDE-1-TITLE-HERE

Replace these every slider sentences with your featured post descriptions.Go to Blogger edit html and find these sentences.Now replace these with your own descriptions.This theme is Bloggerized by Lasantha - Premiumbloggertemplates.com[...]

SLIDE-2-TITLE-HERE

Replace these every slider sentences with your featured post descriptions.Go to Blogger edit html and find these sentences.Now replace these with your own descriptions.This theme is Bloggerized by Lasantha - Premiumbloggertemplates.com[...]

SLIDE-3-TITLE-HERE

Replace these every slider sentences with your featured post descriptions.Go to Blogger edit html and find these sentences.Now replace these with your own descriptions.This theme is Bloggerized by Lasantha - Premiumbloggertemplates.com[...]

If you are going [...]

SLIDE-4-TITLE-HERE

Replace these every slider sentences with your featured post descriptions.Go to Blogger edit html and find these sentences.Now replace these with your own descriptions.This theme is Bloggerized by Lasantha - Premiumbloggertemplates.com[...]

SLIDE-5-TITLE-HERE

Replace these every slider sentences with your featured post descriptions.Go to Blogger edit html and find these sentences.Now replace these with your own descriptions.This theme is Bloggerized by Lasantha - Premiumbloggertemplates.com[...]

Thursday, October 7, 2010

Setting Properties Object dalam form secara global dengan code pada vb 6

Code di bawah ini digunakan untuk menyeragamkan properties object tertentu dalam sebuah form.

Tambahkan sebuah Module ke dalam Project Anda, kemudian copy-Paste code dibawah ini :
Sub setCursor(frm As Form)
On Error Resume Next
Dim obj As Control
For Each obj In frm.Controls
    If TypeOf obj Is CommandButton Then
            obj.MousePointer = 99
            Set obj.MouseIcon = LoadPicture(App.Path & "\HAND-M.CUR")

    End If
Next
End Sub

Sub setColor(frm As Form, color As ColorConstants)
On Error Resume Next
Dim obj As Control
For Each obj In frm.Controls
    If TypeOf obj Is TextBox Then
        obj.BackColor = color
    End If
Next

End Sub

Sub setValue(frm As Form, teks As String)
On Error Resume Next
Dim obj As Control
For Each obj In frm.Controls
    If TypeOf obj Is TextBox Then
        obj.Text = teks
    End If
Next

End Sub

Sub setLabel(frm As Form)
On Error Resume Next
Dim obj As Control
For Each obj In frm.Controls
    If TypeOf obj Is Label Then
        obj.AutoSize = True
        obj.BackStyle = 0
    End If
Next
End Sub
Kemudian tambahkan sebuah Form dan beberapa object dibawah ini
1. Label (Jumlah bebas)
2. ComboBox (1 buah)
3. TextBox (Jumlah bebas)
4. CommandButton (Jumlah bebas)


Selanjutnya COPAS kode dibawah ini kedalam jendela coding form tersebut :

Private Sub Combo1_Click()
Select Case Combo1.ListIndex
Case 0
setColor Me, vbRed
Case 1
setColor Me, vbWhite
Case 2
setColor Me, vbGreen

End Select
End Sub

Private Sub Command1_Click()
setValue Me, ""

End Sub

Private Sub Form_Load()
Combo1.AddItem "Merah"
Combo1.AddItem "putih"
Combo1.AddItem "hijau"

setCursor Me
setColor Me, vbWhite
setValue Me, ""
setLabel Me
End Sub
Source Code :

By Nur Suhadi with No comments

    • Popular
    • Categories
    • Archives