I've designed a userform using Frames. I'm new to frames and trying to learn how to utilize them. Right now I've got 4 frames (the number of frames will be 11 when I'm done building the userform), and each one of them has a different number of textboxes in them. In the UserForm1.Initialize sub, I'm trying to arrange all of my textboxes. Right now I've got it set up to set the top and left properties of each textbox individually, but thought I might be able to accomplish this using a loop. What I'm not sure of is how to get it to go to the next frame once it has lined up the textboxes in the first frame. Does that make sense?
Here's a bit of code I made that works to line them up the way I want, but because it doesn't reference the frames, then after the first frame the textboxes top property is not right.
Here's a bit of code I made that works to line them up the way I want, but because it doesn't reference the frames, then after the first frame the textboxes top property is not right.
Code:
[FONT=Calibri][SIZE=3][COLOR=#000000]Private SubUserForm_Initialize()[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]Dim fCont AsControl[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]Dim txtCountAs Integer[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]txtCount = 0[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]
For Each fCont In Me.Controls[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] If TypeName(fCont) = "TextBox" Then txtCount = txtCount + 1[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]Next fCont[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT][FONT=Calibri][SIZE=3][COLOR=#000000]'LINE UP ALLTEXTBOXES[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]For i = 5 To txtCount[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] With Me.Controls("TextBox" & i)[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] .Width = 40[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] .Top = Me.Controls("TextBox" & i - 2).Top + Me.Controls("Textbox" & i - 2).Height + 10[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] .Left = Me.TextBox3.Left[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] Me.Controls("TextBox" & i) = ""[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] i = i + 1[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] End With[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]Next i[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT][FONT=Calibri][SIZE=3][COLOR=#000000]For i = 6 To txtCount[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] With Me.Controls("TextBox" & i)[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] .Width = 40[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] .Top = Me.Controls("TextBox" & i - 2).Top + Me.Controls("Textbox" & i - 2).Height + 10[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] .Left = Me.TextBox4.Left[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] Me.Controls("TextBox" & i) = ""[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] I = i + 1[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] End With[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]Next i[/COLOR][/SIZE][/FONT]