Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adjusting substring length in label captions. 1

Status
Not open for further replies.

Weltman

Programmer
Apr 27, 2001
17
US
I have an array of labels whose captions list candidates on a ballot. I want to make the captions of equal length regardless of some variations in the length of the candidates' names. Right now, I have the following code:
Number = 32 - (Len(CandidateName) + Len(Affiliation))
NewBallotPage.Label1(IndexNumber).Caption = CandidateName & String(Number, Chr(45)) & Affiliation
I want to use a substring of hyphens to make the captions of equal length, such as the following.
BUSH-----------------------(REP)
BUCHANAN-------------------(RPA)
I am currently using Ms Sans Serif, Fontsize 8. The problem is that the code above does not result in captions of equal length. The hyphen (Chr45) is not as wide as the characters used in the names. The result is that the second caption is longer. It's important that I use code to enter the captions at run time. What can I do about it?
 
Try this?
Two lables, fir and sec both left justified.
fir.AutoSize = false.
sec.Autosize = true.
fir.Caption = Rtrim(name) & String(100,"-")
sec.Caption = Rtrim(Party)
sec.Left = fir.Left + fir.Width - sec.Width.
sec.Zorder 0 ' put second on top.
 
JohnYingling,
There's a possibility that I don't fully understand your
suggestion, but let me try to further clarify what I'm trying to do.
I have an array of labels. Other than the first (index 0), the labels are created at run time. Just to the right of each label is an option button. The option buttons are also an array created at run time with code as follows:
Load NewBallotPage.Label1(IndexNumber)
Load NewBallotPage.Option1(IndexNumber)
There will normally be several sets of these labels and option buttons displayed in a frame with the second set directly below the first set; the 3rd set below the 2nd, etc. Maybe you would like to look at my sample ballots at ballotscentral.com. I don't have the problem there because the labels were created at design time. As I said in my posting above, it's important that I be able to create the ballot at run time. Anyway, I don't want to resize a label because of the option button just to the right.
 
Define a 2nd array of labels corresponding to the 1st array. These labels will contain the Party. You autosize the 2nd label then shift its rihgtmost edge to the rightmost edge of the 1st (Name) label and sec.zorder 0 it to put it on top of the 1st label.
Code:
set 1st label.
+__________________________________+ +___+
|Bush------------------------------| |opt|
+__________________________________+ +___+
set 2nd label +_____+ 
              | REP |
              +_____+
' Move 2nd label of right end of 1st label.
sec.Move (fir.Left + fir.Width - sec.width), fir.top
sec.zorder 0

+____________________________+______+ +___+
|Bush------------------------|-REP--| |opt|
+____________________________|______+ +___+
 
JohnYingling,
That's Wonderful! It Works Just fine.
Thank you very much.
Weltman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top