میلاد علوی
سه شنبه 07 آذر 1391, 19:57 عصر
سلام
با توجه به کد زیر ،سوال من اینه که چجوری بفهمم که txtTextBox در فرم هست یا نه ؟؟ در ضمن از طریق is nothing و is object هم ارور می دهد
' This program demonstrates how you can add and delete
' controls on your form dynamically.
' Creates text box and label.
Private Sub cmdCreate_Click()
' Creates label. controls.Add function takes three variables.
' first ("vb.label") accepts what type of control you want created,
' second ("lblLabel1") accepts the name of the control, the last
' one (frmControl) accepts where you want this control to be placed.
Set ctlName = frmControl.Controls.Add("vb.label", "lblLabel1", frmControl)
' Make controls visible. This step is required if you want the control
' to be visible.
ctlName.Visible = True
' Move positions the control requires four arguments
' (left, top, width, height)
ctlName.Move 500, 500, 1500, 250
ctlName.Caption = "Label 1"
Set ctlName = _
frmControl.Controls.Add("vb.textbox", "txtTextBox", frmControl)
ctlName.Visible = True
ctlName.Move 2000, 500, 1500, 250
End Sub
' Quits the program.
Private Sub cmdExit_Click()
End
End Sub
' Removes the controls created in the cmdCreate_Click()
' procedure.
Private Sub cmdRemove_Click()
frmControl.Controls.Remove "txtTextBox"
frmControl.Controls.Remove "lblLabel1"
End Sub
با تشکر
با توجه به کد زیر ،سوال من اینه که چجوری بفهمم که txtTextBox در فرم هست یا نه ؟؟ در ضمن از طریق is nothing و is object هم ارور می دهد
' This program demonstrates how you can add and delete
' controls on your form dynamically.
' Creates text box and label.
Private Sub cmdCreate_Click()
' Creates label. controls.Add function takes three variables.
' first ("vb.label") accepts what type of control you want created,
' second ("lblLabel1") accepts the name of the control, the last
' one (frmControl) accepts where you want this control to be placed.
Set ctlName = frmControl.Controls.Add("vb.label", "lblLabel1", frmControl)
' Make controls visible. This step is required if you want the control
' to be visible.
ctlName.Visible = True
' Move positions the control requires four arguments
' (left, top, width, height)
ctlName.Move 500, 500, 1500, 250
ctlName.Caption = "Label 1"
Set ctlName = _
frmControl.Controls.Add("vb.textbox", "txtTextBox", frmControl)
ctlName.Visible = True
ctlName.Move 2000, 500, 1500, 250
End Sub
' Quits the program.
Private Sub cmdExit_Click()
End
End Sub
' Removes the controls created in the cmdCreate_Click()
' procedure.
Private Sub cmdRemove_Click()
frmControl.Controls.Remove "txtTextBox"
frmControl.Controls.Remove "lblLabel1"
End Sub
با تشکر