Membuat Gambar yang mengikuti mouse pada Visual Basic 2008/vb.net

Monday, June 2, 2014

Sebenarnya untuk Membuat Gambar yang mengikuti mouse pada Visual Basic 2008/vb.net sangatlah simple dan mudah sekali jika sudah sedikit tahu tentang kode visual basic 2008 karena kodenya sangat simple dan tidak terlalu banyak.
Tahap awal dalam Pembuatan program ini adalah membuat form dan berikan komponen:
  • 1 Timer
  • 1 Picturebox
Langkah pertama masukkan gambar apa saja kedalam picturebox kemudian klik2 kali formnya, hapus semua kode yang ada lalu masukkan kode dibawah:

Public Class Form1



    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        PictureBox1.Left = MousePosition.X
        PictureBox1.Top = MousePosition.Y - 20
        If PictureBox1.Left = Me.Right Then
            PictureBox1.Left -= 10
        ElseIf PictureBox1.Top > Me.Bottom Then
            PictureBox1.Top += 10
        End If
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Timer1.Enabled = True
        Me.WindowState = FormWindowState.Maximized
    End Sub
End Class
 
Share this article :

0 comments:

Speak up your mind

Tell us what you're thinking... !

Komentar Terbaru

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. artikel visual basic - All Rights Reserved
Template Created by Creating Website Inspired by Sportapolis Shape5.com
Proudly powered by Blogger