D
DennisE
I have a UserForm on which I've placed a great many TextBoxes
named TextBox01 through TextBox50, with Tabindex 0 through 49,
respectively. I now want to write their contents to a file and have
written the following real simple code after opening a sequential file:
Dim ctl as Control
For Each ctl in UserForm.Controls
if Typename(ctl) = "TextBox" then Print #1, ctl.Text
Next
Close #1
What happens, however, is that the resultant file contains the
contents of TextBoxes in a seemingly random order, which
has no relationship to the alphanumeric ordering of the TextBox
names or their respective Tabindexes. When I pull up the list
of controls using Project Explorer, they all appear in proper
alphanumeric order. My immediate work-around has been
to modify the above procedure to extract the right two characters
of the control name and use these as a subscript for a one-
dimensional array to temporarily store the data, and then to
print the temporary file in sequential order. My question is,
is there a way to force Excel to inherently reference the
TextBoxes so that I do not have to resort to messy code
and have the simple version above do the job?
-- Dennis Eisen
named TextBox01 through TextBox50, with Tabindex 0 through 49,
respectively. I now want to write their contents to a file and have
written the following real simple code after opening a sequential file:
Dim ctl as Control
For Each ctl in UserForm.Controls
if Typename(ctl) = "TextBox" then Print #1, ctl.Text
Next
Close #1
What happens, however, is that the resultant file contains the
contents of TextBoxes in a seemingly random order, which
has no relationship to the alphanumeric ordering of the TextBox
names or their respective Tabindexes. When I pull up the list
of controls using Project Explorer, they all appear in proper
alphanumeric order. My immediate work-around has been
to modify the above procedure to extract the right two characters
of the control name and use these as a subscript for a one-
dimensional array to temporarily store the data, and then to
print the temporary file in sequential order. My question is,
is there a way to force Excel to inherently reference the
TextBoxes so that I do not have to resort to messy code
and have the simple version above do the job?
-- Dennis Eisen