Visual Studio Development Bookmark and Share   
 index > Visual Basic Express Edition > Code for mouse moving to right or left
 

Code for mouse moving to right or left

I need some code, something like this:
- if the mouse start movingto the right side .. then .....
or
- if the mousestart moving to the left, then ---
Is there such thing?
Thanks in advance. Robi1955
robi1955  Friday, September 04, 2009 5:34 PM
Public Class Form1
    Dim last As New Point()


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.BackColor = Color.White
    End Sub

    Private Sub Form1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
        If last = Nothing Then
            last.X = e.X
            last.Y = e.Y

        ElseIf e.X > last.X Then
            Me.BackColor = Color.Blue
            last.X = e.X
        Else
            Me.BackColor = Color.Red
            last.X = e.X

        End If
    End Sub
End Class

Kenneth
  • Marked As Answer byrobi1955 Saturday, September 05, 2009 5:59 AM
  •  
Kenneth Haugland  Friday, September 04, 2009 7:43 PM

only when your form is active or for all the time, even when your form is not focused/minimized ?
Thanks

â™?My Blog â™?My Flickr â™?My Facebook â™?/div>
Omie  Friday, September 04, 2009 6:58 PM
Public Class Form1
    Dim last As New Point()


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.BackColor = Color.White
    End Sub

    Private Sub Form1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
        If last = Nothing Then
            last.X = e.X
            last.Y = e.Y

        ElseIf e.X > last.X Then
            Me.BackColor = Color.Blue
            last.X = e.X
        Else
            Me.BackColor = Color.Red
            last.X = e.X

        End If
    End Sub
End Class

Kenneth
  • Marked As Answer byrobi1955 Saturday, September 05, 2009 5:59 AM
  •  
Kenneth Haugland  Friday, September 04, 2009 7:43 PM
kenneth , nice code. ;o)
how would i go about moving the mouse up/down?
i live here and this is my reason.. trujade.
trujade  Friday, September 04, 2009 10:20 PM
    Private Sub Form1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
        If last = Nothing Then
            last.X = e.X
            last.Y = e.Y
        ElseIf e.Y > last.Y Then
            Me.BackColor = Color.Red
        Else
            Me.BackColor = Color.Purple
        End If
        last.Y = e.Y
        last.X = e.X
    End Sub

Kenneth
  • Proposed As Answer byShariqDON Saturday, October 17, 2009 11:37 PM
  •  
Kenneth Haugland  Friday, September 04, 2009 10:28 PM
thanx kenneth . ;o)

i live here and this is my reason.. trujade.
trujade  Friday, September 04, 2009 10:36 PM
Good
ShariqDON  Saturday, October 17, 2009 11:37 PM

You can use google to search for other answers

Custom Search

More Threads

• What platform?
• Access to file on LAN was denied
• building dictionary
• How do i save a Label with Text and Merge it with a Bitmap/Image file?
• Run my application without framework
• How to make new textbox input rows??
• OpenFileDialog with MyComputer as Initial Directory
• ListView sorting question
• Transparent Gifs
• NEW - Changing Header - Your Name Here ?