[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Help with control array positioning

Posted on 2006-05-12
4
Medium Priority
?
155 Views
Last Modified: 2010-05-01
I want these labels to be laid out 'as close together' as would appear pleasing to the eye.
I also don't want them to extend off the side of the form.

Having a bit of trouble with the logic on the second line of labels...
Here's the relevant code

Load lblData(x)
With lblData(x)
 If x = 7 Then 'This is the 'first' of these labels (there are obviously 7 others, but they're static)
  intTop = 2665  'The first label's top
  intLeft = 280  'The first label's left
Else
  intLeft = lblData(x - 1).Left + lblData(x - 1).Width + 100  'Otherwise - add the left & width to 100 to get the 'new' left (this could use some tweaking, I'd wager)
  If intLeft > 6500 Then  'If left is 'dangerously' close to the form's edge, then change the 'top' and reset the 'left'  (obviously the left would be okay, but though it's 'unlikely' to have more than 2 rows, I want to give the option for at least 3...
  intTop = 3065
  intLeft = 280
 Else
  intTop = 2665
  intLeft = lblData(x - 1).Left + lblData(x - 1).Width + 100
 End If
End If
 .Caption = txtData(1).Text
 .Width = 1000
 .Height = 255
 .Top = intTop
 .Left = intLeft
 .Visible = True
End With
0
Comment
Question by:sirbounty
  • 2
  • 2
4 Comments
 
LVL 8

Accepted Solution

by:
Leo Eikelman earned 1000 total points
ID: 16668210
I think the problem you are having is this line

 If intLeft > 6500 Then  
  intTop = 3065
  intLeft = 280
 Else
  intTop = 2665
  intLeft = lblData(x - 1).Left + lblData(x - 1).Width + 100

You first item on the second row will get printed correctly but then every other control will be printer up on the first line again because you have intTop being set to 2665 again.  Get rid of the intTop = 2665 line here and set intTop = 2665 outside of your loop.  So the default value for intTop is 2665.  

You should only have to change the intTop value when you move onto a new line.  You don't have to change or specify the value every time you display a control on the same line.


Leo
0
 
LVL 8

Expert Comment

by:Leo Eikelman
ID: 16668222
Also,

At this line

 If intLeft > 6500 Then  
  intTop = 3065
  intLeft = 280
 Else
 

change intTop to something like

intTop = intTop + 400


Leo
0
 
LVL 67

Author Comment

by:sirbounty
ID: 16668253
Works up until item 2 on line 2...
0
 
LVL 67

Author Comment

by:sirbounty
ID: 16668289
Ok - made intTop a form variable and it's working.
Thanx.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month18 days, 8 hours left to enroll

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question