Monday, January 27, 2014

Fugitive Buttons in Visual Basic 2010 / 2012 - Simple Codes

Hi,

Fugitive Buttons in Visual Basic, Insert 1 button in form. And paste the code;

Public Class Form1

    Dim try_count, val As Integer
    Dim rndm As New Random

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.Size = New Size(My.Computer.Screen.WorkingArea.Width, My.Computer.Screen.WorkingArea.Height)
        Me.WindowState = FormWindowState.Maximized      'For fullscreen form
        Me.AcceptButton = Nothing
    End Sub

    Private Sub Button1_MouseMove(sender As Object, e As MouseEventArgs) Handles Button1.MouseMove

        Button1.Location = New Point(rndm.Next(170, Me.Size.Width - 170), rndm.Next(75, Me.Size.Height - 75))
        try_count = try_count + 1
        Me.Text = "Try : " & try_count.ToString

    End Sub


    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        MsgBox("congratulations!", MsgBoxStyle.MsgBoxRight, "congratulations")

    End Sub

End Class

Good Bye...

No comments:

Post a Comment