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

Fitxer: m1p4.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 Form1 
   Appearance      =   0  'Flat
   BackColor       =   &H00004000&
   Caption         =   "Cronòmetre"
   ClientHeight    =   1215
   ClientLeft      =   2115
   ClientTop       =   1590
   ClientWidth     =   5700
   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     =   1215
   ScaleWidth      =   5700
   Begin VB.TextBox txtTranscorregut 
      Appearance      =   0  'Flat
      Enabled         =   0   'False
      Height          =   285
      Left            =   4200
      TabIndex        =   7
      Top             =   840
      Width           =   1335
   End
   Begin VB.TextBox txtAturada 
      Appearance      =   0  'Flat
      Enabled         =   0   'False
      Height          =   285
      Left            =   4200
      TabIndex        =   6
      Top             =   480
      Width           =   1335
   End
   Begin VB.TextBox txtInici 
      Appearance      =   0  'Flat
      Enabled         =   0   'False
      Height          =   285
      Left            =   4200
      TabIndex        =   5
      Top             =   120
      Width           =   1335
   End
   Begin VB.CommandButton cmdAturada 
      Appearance      =   0  'Flat
      Caption         =   "Aturar cronòmetre"
      Enabled         =   0   'False
      Height          =   375
      Left            =   240
      TabIndex        =   1
      Top             =   720
      Width           =   1815
   End
   Begin VB.CommandButton cmdInici 
      Appearance      =   0  'Flat
      Caption         =   "Iniciar cronòmetre"
      Height          =   375
      Left            =   240
      TabIndex        =   0
      Top             =   120
      Width           =   1815
   End
   Begin VB.Label Label3 
      Alignment       =   1  'Right Justify
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "Temps transcorregut:"
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   2280
      TabIndex        =   4
      Top             =   840
      Width           =   1815
   End
   Begin VB.Label Label2 
      Alignment       =   1  'Right Justify
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "Hora d'aturada:"
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   2280
      TabIndex        =   3
      Top             =   480
      Width           =   1815
   End
   Begin VB.Label Label1 
      Alignment       =   1  'Right Justify
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "Hora d'inici:"
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   2280
      TabIndex        =   2
      Top             =   120
      Width           =   1815
   End
End


Codi del programa. Programació de respostes a events

Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim HoraInici As Variant

Private Sub cmdAturada_Click()
    Dim HoraAturada As Variant
    Dim TempsTranscorregut As Variant
    HoraAturada = Now
    TempsTranscorregut = HoraAturada - HoraInici
    txtAturada.Text = Format(HoraAturada, "hh:mm:ss")
    txtTranscorregut.Text = Format(TempsTranscorregut, "hh:mm:ss")
    cmdAturada.Enabled = False
    cmdInici.Enabled = True
End Sub

Private Sub cmdInici_Click()
    HoraInici = Now
    txtInici = Format(HoraInici, "hh:mm:ss")
    txtAturada.Text = ""
    txtTranscorregut = ""
    cmdAturada.Enabled = True
    cmdInici.Enabled = False
End Sub