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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

right alignment

Status
Not open for further replies.

geethanandh

Programmer
Jun 5, 2002
21
0
0
US
hello
i am placing a string in a picture box at X,Y position like this
Picture1.CurrentX = 50
Picture1.CurrentY = 100
Picture1.Print "Hello"
In this case i am specifying the left position of the string, is there any way i can specify the right most position of the string so that the string can be roght aligned.
Pls help me

bye
geethanandh
 
This might help. Set your picture boxes ScaleMode to Character and choose a fixed width font (Courier New) and adjust the width to the picture box so that the ScaleWidth is a whole number. (Width = 2465 -> ScaleWidth ->20). Then drop this code in a command button.

Private Sub Command1_Click()
Dim sPad As String
Dim sTmp As String

sTmp = "First"
sPad = Space$(pic.ScaleWidth - Len(sTmp))
pic.Print sPad & sTmp
sTmp = "NextValue"
sPad = Space$(pic.ScaleWidth - Len(sTmp))
pic.Print sPad & sTmp

End Sub

There might be another way but this was just something I thought I would throw out as it might be all you are looking for. Hope this helps. If you choose to battle wits with the witless be prepared to lose.
[machinegun][ducky]
 
What you might want to try is to use the Picture1.TextWidth Method which will return the amount of space that a given text string with require, at the given font settings for the picture box.

If then you determine the Ending point of the strings that you wish to print right justified, you can subtract the TextWidth from that point, which is where you would being printer.

Assuming that you want the printing to END of position 2000, then something like the following:

Picture1.CurrentX = 2000 - Picture1.TextWidth(OutputString)
Picture1.Print OutputString

Use the same ending point for all of your strings.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top