PROGRAMACIÓ D'APLICACIONS EDUCATIVES AMB VISUAL BASICMÒDUL 1

Fitxer: m2p4.frm

Definició dels objectes. Interfície d'usuari

Recordeu que això no ho podeu editar directament. Per fer-ho incorporeu nous objectes de la paleta en el vostre formulari. I per canviar els valors seleccioneu l'objecte i escolliu la propietat a canviar en la finestra Properties.

VERSION 5.00
Begin VB.Form frmMoviment 
   Appearance      =   0  'Flat
   BackColor       =   &H80000005&
   Caption         =   "Moviment"
   ClientHeight    =   2040
   ClientLeft      =   1905
   ClientTop       =   2250
   ClientWidth     =   4800
   BeginProperty Font 
      Name            =   "MS Sans Serif"
      Size            =   8.25
      Charset         =   0
      Weight          =   700
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   ForeColor       =   &H80000008&
   LinkTopic       =   "Form1"
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   2040
   ScaleWidth      =   4800
   Begin VB.PictureBox picCercle 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      BorderStyle     =   0  'None
      ForeColor       =   &H80000008&
      Height          =   615
      Left            =   240
      ScaleHeight     =   615
      ScaleWidth      =   615
      TabIndex        =   0
      Top             =   960
      Width           =   615
      Begin VB.Shape shpCercle 
         BackColor       =   &H000000FF&
         BackStyle       =   1  'Opaque
         BorderStyle     =   0  'Transparent
         Height          =   495
         Left            =   0
         Shape           =   3  'Circle
         Top             =   0
         Width           =   615
      End
   End
   Begin VB.Timer trmRellotge 
      Interval        =   10
      Left            =   240
      Top             =   240
   End
End


Codi del programa. Programació de respostes a events

Attribute VB_Name = "frmMoviment"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Option Explicit

Const MovCercleAturat = 0
Const MovCercleVertical = 1
Const MovCercleHoritzontal = 2
Const MovCercleDiagonal = 3
Dim EstatCercle As Integer

Private Sub Form_Load()
    EstatCercle = MovCercleAturat
End Sub

Private Sub picCercle_Click()
    EstatCercle = (EstatCercle + 1) Mod 4
End Sub

Private Sub trmRellotge_Timer()
    Dim X, Y As Integer
    Select Case EstatCercle
        Case MovCercleAturat
            X = picCercle.Left
            Y = picCercle.Top
        Case MovCercleHoritzontal
            X = (picCercle.Left + 50) Mod frmMoviment.Width
            Y = picCercle.Top
        Case MovCercleVertical
            X = picCercle.Left
            Y = (picCercle.Top + 50) Mod frmMoviment.Height
        Case MovCercleDiagonal
            X = (picCercle.Left + 50) Mod frmMoviment.Width
            Y = (picCercle.Top + 50) Mod frmMoviment.Height
     End Select
     picCercle.Move X, Y
End Sub