

Fitxer: m2p1.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 = &H80000005&
Caption = "Sumar o multiplicar"
ClientHeight = 3330
ClientLeft = 1680
ClientTop = 1410
ClientWidth = 4920
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 = 3330
ScaleWidth = 4920
Begin VB.TextBox txtTaula
Appearance = 0 'Flat
Enabled = 0 'False
ForeColor = &H00C00000&
Height = 2055
Left = 2760
MultiLine = -1 'True
TabIndex = 7
Top = 960
Width = 1815
End
Begin VB.TextBox txtNúmeroTaula
Appearance = 0 'Flat
Height = 285
Left = 3720
TabIndex = 6
Top = 360
Width = 855
End
Begin VB.Frame recOpcions
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "Que voleu fer?"
ForeColor = &H80000008&
Height = 975
Left = 480
TabIndex = 2
Top = 360
Width = 1815
Begin VB.OptionButton OpMultiplicar
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "Multiplicar"
ForeColor = &H80000008&
Height = 255
Left = 120
TabIndex = 4
Top = 600
Width = 1455
End
Begin VB.OptionButton OptSumar
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "Sumar"
ForeColor = &H80000008&
Height = 255
Left = 120
TabIndex = 3
Top = 240
Value = -1 'True
Width = 1695
End
End
Begin VB.CommandButton cmdFí
Appearance = 0 'Flat
Caption = "&Fí"
Height = 375
Left = 480
TabIndex = 1
Top = 2520
Width = 1815
End
Begin VB.CommandButton cmdCalcular
Appearance = 0 'Flat
Caption = "&Calcular"
Height = 375
Left = 480
TabIndex = 0
Top = 1920
Width = 1815
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "Taula del:"
ForeColor = &H80000008&
Height = 255
Left = 2640
TabIndex = 5
Top = 360
Width = 975
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
Private Sub cmdCalcular_Click()
EmplenarTaula
End Sub
Private Sub cmdFí_Click()
End
End Sub
Private Sub EmplenarTaula()
Dim i As Integer
Dim NúmeroTaula As Integer
Dim Taula As String
NúmeroTaula = Val(txtNúmeroTaula)
If OptSumar Then
For i = 1 To 10
Taula = Taula + Str$(NúmeroTaula) + "+" + Str$(i) + "="
Taula = Taula + Str$(NúmeroTaula + i) + Chr$(13) + Chr$(10)
Next i
Else
For i = 1 To 10
Taula = Taula + Str$(NúmeroTaula) + "*" + Str$(i) + "="
Taula = Taula + Str$(NúmeroTaula * i) + Chr$(13) + Chr$(10)
Next i
End If
txtTaula.Text = Taula
End Sub
Private Sub txtNúmeroTaula_KeyDown(keycode As Integer, Shift As Integer)
If keycode = 13 Then EmplenarTaula
End Sub