I am trying to use a button in a userform so when I press it it will resize the form and put a new textbox in the form. I am also trying to put some code in for a change event for the new textbox.. this is what I have for code so far.. everything works except for the code for the new textbox. thanks
Private Sub NewScanbtn_Click()
Dim i As Integer
Dim strNewName As String
Dim NewTextBoxTop As Integer
Dim objNewName As Object
Dim Line As Integer
Dim UF As Object
'--------------------------
'XXXXXXXXXXXXXXXXXXXXXXXXXX
'--------------------------
i = Me.Counter.Value
NewTextBoxTop = Me.Height - 90
strNewName = "Scan" & i
'//Textbox for FailValue, value input in EQDCS
Set objNewName = ScanTrayForm.Controls.Add("forms.Textbox.1", strNewName, True)
With objNewName
.Name = strNewName
.Height = 23.25
.Width = 180.05
.Top = NewTextBoxTop
.Left = 30
.Visible = True
End With
Set UF = ActiveWorkbook.VBProject.VBComponents("ScanForm")
With UF.CodeModule
Line = .CountOfLines
.InsertLines Line + 1, _
"Private Sub " & objNewName.Name & "_Change()" & Chr(13) & _
" msgbox strNewName" & Chr(13) & _
"End Sub"
End With
Me.Height = Me.Height + 30
Me.NewScanbtn.Top = Me.NewScanbtn.Top + 30
Me.NewScanbtn.Left = 60
Me.Counter.Value = Me.Counter.Value + 1
End Sub
Bookmarks