Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
2.00/5 (3 votes)
See more:
Whats the problem with this code?

VB
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    If (Cursor.Position = New Point(Me.Location.X >= 350, Me.Location.Y)) Then
        MessageBox.Show("LOL")
    End If

End Sub
Posted
Comments
LloydA111 13-Mar-11 17:37pm    
Don't use a timer for this, instead use "Form1_MouseMove".

You can find the bugs to compile the code, but it won't help. As the name of the method suggests (the name violates Microsoft naming rules), it will be called on timer tick. What, you really want unlimited number text boxes on top of each other?

Just don't do it. One step further: don't use timer, especially System.Windows.Forms.Timer. Too boring to explain why…
Better, you explain why using it? Just to try? This I can understand…

—SA
 
Share this answer
 
v2
Comments
Espen Harlinn 13-Mar-11 16:43pm    
My 5 - Good points, OP might be pulling our collective legs though - this may be a hint: MessageBox.Show("LOL")
Sergey Alexandrovich Kryukov 13-Mar-11 17:09pm    
It can be a hint, right, I pay attention for this in first place. "Just for luzls" is a valid justification... :-)
Thank you, Espen.
--SA
It's written in VB? :)

Seriously, a Point requires two integers, not a bool and an int. You can't do the compare as one of the two parameters.

What are you actually trying to do?


"If my cursor reaches past a certain point of the app it will do something"


Then try:
If (Cursor.Position.X >= 350)
   ...
End If
 
Share this answer
 
v2
Comments
[no name] 13-Mar-11 5:40am    
If my cursor reaches past a certain point of the app it will do something
OriginalGriff 13-Mar-11 6:08am    
Answer updated.
Espen Harlinn 13-Mar-11 7:23am    
It's written in VB - that's worth a 5 - Apart from that, you obviously got the soul and patience of a saint :)
Sergey Alexandrovich Kryukov 13-Mar-11 15:47pm    
Main problem is using timer.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900