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

Fitxer: m6p2.frm

Definició dels objectes. Interfície d'usuari.

Recordeu que això no ho podeu editar directament. Per editar-ho es fa incorporant nous objectes de la paleta en el vostre formulari. I per canviar els valors ho feu sel.leccionant l'objecte i escolliu la propietat a canviar en la finestra Properties.

VERSION 5.00
Begin VB.Form Form1 
   Appearance      =   0  'Flat
   BackColor       =   &H80000005&
   Caption         =   "Eixos de coordenades"
   ClientHeight    =   4215
   ClientLeft      =   1500
   ClientTop       =   1740
   ClientWidth     =   6945
   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     =   4215
   ScaleWidth      =   6945
   Begin VB.CommandButton cmdAplicaEscala 
      Appearance      =   0  'Flat
      Caption         =   "Aplica Escala"
      Height          =   375
      Left            =   4320
      TabIndex        =   9
      Top             =   3240
      Width           =   2175
   End
   Begin VB.CommandButton cmdEsborra 
      Appearance      =   0  'Flat
      Caption         =   "Esborra"
      Height          =   255
      Left            =   5640
      TabIndex        =   15
      Top             =   1440
      Width           =   855
   End
   Begin VB.CommandButton cmdDibuixa 
      Appearance      =   0  'Flat
      Caption         =   "Dibuixa"
      Height          =   255
      Left            =   4320
      TabIndex        =   14
      Top             =   1440
      Width           =   975
   End
   Begin VB.TextBox txtYB 
      Appearance      =   0  'Flat
      Height          =   285
      Left            =   5760
      TabIndex        =   13
      Top             =   2880
      Width           =   495
   End
   Begin VB.TextBox txtXB 
      Appearance      =   0  'Flat
      Height          =   285
      Left            =   4800
      TabIndex        =   12
      Top             =   2880
      Width           =   495
   End
   Begin VB.TextBox txtYA 
      Appearance      =   0  'Flat
      Height          =   285
      Left            =   5760
      TabIndex        =   11
      Top             =   2160
      Width           =   495
   End
   Begin VB.TextBox txtXA 
      Appearance      =   0  'Flat
      Height          =   285
      Left            =   4800
      TabIndex        =   10
      Top             =   2160
      Width           =   495
   End
   Begin VB.CommandButton cmdEscalaReal 
      Appearance      =   0  'Flat
      Caption         =   "Escala en mil·límetres"
      Height          =   375
      Left            =   4320
      TabIndex        =   8
      Top             =   3600
      Width           =   2175
   End
   Begin VB.PictureBox picCoordenades 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      ForeColor       =   &H80000008&
      Height          =   3135
      Left            =   360
      ScaleHeight     =   3105
      ScaleWidth      =   3465
      TabIndex        =   0
      Top             =   600
      Width           =   3495
   End
   Begin VB.Label Label9 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "Y="
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   5400
      TabIndex        =   21
      Top             =   2880
      Width           =   375
   End
   Begin VB.Label Label8 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "X="
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   4440
      TabIndex        =   20
      Top             =   2880
      Width           =   375
   End
   Begin VB.Label Label7 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "Y="
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   5400
      TabIndex        =   19
      Top             =   2160
      Width           =   375
   End
   Begin VB.Label Label6 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "X="
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   4440
      TabIndex        =   18
      Top             =   2160
      Width           =   375
   End
   Begin VB.Label Label5 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "Vèrtex B"
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   4440
      TabIndex        =   17
      Top             =   2640
      Width           =   855
   End
   Begin VB.Line Line1 
      X1              =   4440
      X2              =   6360
      Y1              =   2520
      Y2              =   2520
   End
   Begin VB.Label Label4 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "Vèrtex A"
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   4440
      TabIndex        =   16
      Top             =   1800
      Width           =   855
   End
   Begin VB.Shape Shape2 
      Height          =   1455
      Left            =   4320
      Top             =   1800
      Width           =   2175
   End
   Begin VB.Label lblMidaAlt 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "Label5"
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   5160
      TabIndex        =   7
      Top             =   1080
      Width           =   1335
   End
   Begin VB.Label lblMidaAmple 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   5160
      TabIndex        =   6
      Top             =   720
      Width           =   1335
   End
   Begin VB.Label Label3 
      Alignment       =   1  'Right Justify
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "Alçada:"
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   4200
      TabIndex        =   5
      Top             =   1080
      Width           =   855
   End
   Begin VB.Label Label2 
      Alignment       =   1  'Right Justify
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "Amplada:"
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   4200
      TabIndex        =   4
      Top             =   720
      Width           =   855
   End
   Begin VB.Label Label1 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "Mides del quadre de dibuix en mil·límetres"
      ForeColor       =   &H80000008&
      Height          =   375
      Left            =   4200
      TabIndex        =   3
      Top             =   240
      Width           =   2415
   End
   Begin VB.Shape Shape1 
      Height          =   3735
      Left            =   4080
      Top             =   360
      Width           =   2655
   End
   Begin VB.Label lblVèrtexB 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "Vèrtex B"
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   3000
      TabIndex        =   2
      Top             =   3840
      Width           =   855
   End
   Begin VB.Label lblVèrtexA 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "Vèrtex A"
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   360
      TabIndex        =   1
      Top             =   240
      Width           =   855
   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

Private Sub AplicAeSCALA(XA As Single, YA As Single, XB As Single, YB As Single)
    picCoordenades.Scale (XA, YA)-(XB, YB)
    lblMidaAmple.Caption = XB - XA
    lblMidaAlt.Caption = YA - YB
    txtXA = Str(Int(XA))
    txtYA = Str(Int(YA))
    txtXB = Str(Int(XB))
    txtYB = Str(Int(YB))
End Sub

Private Sub cmdAplicaEscala_Click()
    AplicAeSCALA Val(txtXA), Val(txtYA), Val(txtXB), Val(txtYB)

End Sub

Private Sub cmdDibuixa_Click()
    Dim i As Integer
    picCoordenades.Line (-10, -10)-(10, 10), QBColor(5), BF
    For i = 0 To 100 Step 10
        picCoordenades.PSet (i, 0), QBColor(5)
        picCoordenades.PSet (0, i), QBColor(5)
    Next
End Sub

Private Sub cmdEsborra_Click()
    picCoordenades.Cls
End Sub

Private Sub cmdEscalaReal_Click()
    Form_Load
End Sub

Private Sub Form_Load()
    Dim VertexAX As Single
    Dim VertexAY As Single
    Dim VertexBX As Single
    Dim VertexBY As Single
    Dim MidaX As Single
    Dim MidaY As Single
    Dim ConversióTwipsMilímetres As Single

    ConversióTwipsMilímetres = 10 / 567
    MidaX = picCoordenades.Width * ConversióTwipsMilímetres
    MidaY = picCoordenades.Height * ConversióTwipsMilímetres
    VertexAX = -MidaX / 2
    VertexAY = MidaY / 2
    VertexBX = MidaX / 2
    VertexBY = -MidaY / 2
    AplicAeSCALA VertexAX, VertexAY, VertexBX, VertexBY
End Sub