-
June 11th, 2005, 11:12 PM
#1
CType(Sender help
im trying to change the .text property of whatever label is clicked.. to me this makes perfect sense and should run.
Please tell me whats wrong?
Code:
Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click, Label3.Click, Label4.Click, Label5.Click, Label6.Click, Label7.Click, Label8.Click, Label9.Click, Label10.Click
With CType(sender, Label).Name
.text = XOval
End With
End Sub
-
June 12th, 2005, 09:41 PM
#2
Re: CType(Sender help
Code:
CType(sender, Label).Name
Think about this line for a second. How does this makes perfect sense?
Good Luck,
-Cool Bizs
-
June 13th, 2005, 03:49 AM
#3
Re: CType(Sender help
Originally Posted by |2eM!x
Code:
With CType(sender, Label).Name
This line should be changed to:
Code:
With CType(sender, Label)
Reason being is obvious. In your code you are saying: "With the object reference returned by the 'Name' property of the Label reference returned by the CType cast on the sender object..." - In other words, you are "Withing" a String object reference, which has no "Text" property.
The correction I gave would be described as this: "With the object reference returned by the CType cast on the sender object..." - Which would be correct as it returns a Label object reference which does have a "Text" property.
Hope that helps. Was probably just an oversight on your part.
-
June 13th, 2005, 05:26 PM
#4
Re: CType(Sender help
Yes thanks, im new to .net, so that made perfect sense to me..
I thought what i had returned which label i clicked on, but alas now i understand it does not. Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|