hearthhrob4gals
Board Regular
- Joined
- Aug 20, 2014
- Messages
- 142
Hi,
i create multiple textboxes with dynamic names during the run time on userform.
On any of the textbox exit, i need to do some calculation and show the output in a label corresponding to that particular text box.
however the textbox exit event is not working with the dynamic name that i have set
the normal code that works is
however,instead of textbox1, the dynamic textbox name is txt1. i tried replacing textbox1 with txt1. however, it didnt work.
the below code is how i created these textboxes
i create multiple textboxes with dynamic names during the run time on userform.
On any of the textbox exit, i need to do some calculation and show the output in a label corresponding to that particular text box.
however the textbox exit event is not working with the dynamic name that i have set
the normal code that works is
Code:
Private Sub Textbox1_Update(ByVal Cancel As MSForms.ReturnBoolean)
Call doValidation(Textbox1)
End Sub
however,instead of textbox1, the dynamic textbox name is txt1. i tried replacing textbox1 with txt1. however, it didnt work.
the below code is how i created these textboxes
Code:
Dim txtB2 As Control
Dim h
k = 160
For h = 1 To Z
Set txtB2 = Controls.Add("Forms.TextBox.1")
With txtB2
.Name = "txt" & h
.Height = 20
.Width = 50
.Left = 240
If h = 1 Then
.Top = k + 30
Else
.Top = z1 + 30
End If
z1 = .Top
End With
Next h