Pages

Banner 468

Kamis, 06 November 2008

Membuat Control Baru dengan script

 
Public Function LoadControl(oForm As Object, _
CtlType As String, CtlName As String, nTop As Double, nLeft As Double) As Object
'by : eko cahyono(idym : eko_matrix)
Dim oCtl As Object

On Error Resume Next

If IsObject(oForm.Controls) Then
Set oCtl = oForm.Controls.Add(CtlType, CtlName)
If Not oCtl Is Nothing Then Set LoadControl = oCtl
oCtl.Top = nTop
oCtl.Left = nLeft
oCtl.Visible = True

End If

End Function

Private Sub Command1_Click()
LoadControl Form1, "vb.textbox", "text1", 100, 1000
LoadControl Form1, "VB.CommandButton", "Tombol", 1000, 1000
LoadControl Form1, "VB.pictureBox", "Pic", 2200, 1000
End Sub