AnyOne can help me? I am stuck since yesterday. Here is code for what I am trying.
Expand|Select|Wrap|Line Numbers
- Private myControlArray() As Control
- Private userPromtedValue(50) As String
- Public Property Get PublicUserPromtedValue(ByVal Index As Long) As String
- PublicUserPromtedValue = userPromtedValue(Index)
- End Property
- Public Property Let PublicUserPromtedValue(ByVal Index As Long, ByVal NewValue As String)
- userPromtedValue(Index) = NewValue
- End Property
- Public Property Get PublicMyControlArray(ByVal Index As Long) As Control
- PublicMyControlArray = myControlArray(Index)
- End Property
- Public Property Set PublicMyControlArray(ByVal Index As Long, ByVal NewValue As Control)
- Set myControlArray(Index) = NewValue
- End Property
- Private Sub CommandButton1_Click()
- Dim userPromtedValue(1 To 10) As String
- For i = 0 To thisSubsetNo
- Dim myControl As Control
- Set myControl = userForm1.PublicMyControlArray(2 * i + 1)
- userPromtedValue(i) = myControl.Text
- PublicUserPromtedValue(i) = userPromtedValue(i)
- MsgBox "text" & userPromtedValue(i)
- Next i
- Me.Hide
- End Sub
- Private Sub CommandButton2_Click()
- Me.Hide
- End Sub
- Private Sub UserForm_Initialize()
- Dim newTextBox As TextBox
- Dim myControl As Control
- Dim myControl1 As Control
- Dim myControl2 As Control
- Dim myControl12 As Control
- 'Dim myControlArray() As Control
- Dim lngNextTop As Long
- Dim lngTitleBarHeight As Long
- Dim i As Long
- ReDim myControlArray(2 * thisSubsetNo + 1)
- Const cTextBoxHeight As Long = 18
- Const cTextBoxWidth As Long = 70
- Const cGap As Long = 20
- lngTitleBarHeight = Me.Height - Me.InsideHeight
- lngNextTop = cGap
- Load userForm1
- For i = 0 To thisSubsetNo
- 'Create label
- Set myControl = Me.Controls.Add("Forms.Label.1", "myControl")
- With myControl
- .Visible = True
- .Width = cTextBoxWidth
- .Height = cTextBoxHeight
- .Left = cGap
- .Top = lngNextTop
- .Caption = thispath(i)
- End With
- Set userForm1.PublicMyControlArray(2 * i) = myControl
- 'Create textbox
- Set myControl1 = Me.Controls.Add("Forms.TextBox.1", "myControl1")
- With myControl1
- .Visible = True
- .Width = cTextBoxWidth + 50
- .Height = cTextBoxHeight + 5
- .Left = cGap + cTextBoxWidth + cGap
- .Top = lngNextTop
- End With
- Set userForm1.PublicMyControlArray(2 * i + 1) = myControl1
- 'Calculate top position for next control
- lngNextTop = lngNextTop + cTextBoxHeight + cGap
- 'Resize form
- Me.Height = lngNextTop + cTextBoxHeight + cGap
- Next i
- Set myControl = Nothing
- Set myControl1 = Nothing
- End Sub