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

Labels problem idea may be impossiable :) noting click point. 1

Status
Not open for further replies.

Trowser

IS-IT--Management
Dec 16, 2002
125
GB
Ok with a Label
say I have text 255 characters long in a label
and that label contains data from a database that I dont want the user to change

Now say the label has a list of locations where a part is sold at.

Now the user clicks on the label on say a point hovering over say K-mart

is it at all possiable to know where about in that sting the user clicked? IE clicking on K-Mart, or another vendor?

and so that when they click on that area that says K-Mart it brings up a box with information about that vendor?

Prolly inpossiable but if anyone knows someone here prolly does :)
 

Ok, I thought the challenge was interesting so here is some hack code that may help you.
[tt]
Option Explicit

Private Sub Form_Load()
Label1.Caption = "Wal Mart,K-Mart,Target,Joes"
End Sub

Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
FindWord X
End Sub

Private Sub FindWord(DistanceFromLeft As Single)

Dim W As Long, T As Long, I As Integer, MyArray() As String, TestString As String
W = Me.TextWidth(Label1.Caption)
If W > DistanceFromLeft Then

MyArray = Split(Label1.Caption, ",")

For I = 0 To UBound(MyArray)
TestString = TestString & MyArray(I) & ","
T = Me.TextWidth(TestString)
If T > DistanceFromLeft Then
MsgBox MyArray(I)
Exit Sub
End If
Next I

End If

End Sub
[/tt]

Good Luck

 
Thanks VB5 I really didn't think it could be done :)

again I am proven wrong (thankgod)
 
If either of the last two responses work, give the person
a brownie point by hitting the red star at the bottom of the post.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top