Hello
I have many line controls on my form. I want to display a value in the middle of the line control. So when the user moves the line control at run - time, the value will always stay in the centre of the line.
Many thanks in advance
Printable View
Hello
I have many line controls on my form. I want to display a value in the middle of the line control. So when the user moves the line control at run - time, the value will always stay in the centre of the line.
Many thanks in advance
Do you mean you want to display something at the centre of a line, or move the line's centre to where the user clicks??
What to display something at the lines centre
Code:Dim YPos As Single
Dim XPos As Single
With Line1
XPos = .X2 - X1
YPos = .Y2 - Y1
End With
With Label1
.Left = XPos
.Top = YPos
End With
I have tried that code, but it display the label at one end of the line and not the centre.
VB Code:
Label1.left = Line.X1 + ((Line1.X2 - Line1.X1)/2) - (Label1.Width/2) Label1.top = Line.Y1 + ((Line1.Y2 - Line1.Y1)/2)
Call that whenever the line moves.
EDIT: Changed for your objects, and made it place the label properly in the middle.
Thanks for your reply. that piece of code works wonders.
Thanks
Glad i could help :)