home *** CD-ROM | disk | FTP | other *** search
/ An Introduction to Progr…l Basic 6.0 (4th Edition) / An Introduction to Programming using Visual Basic 6.0.iso / PROGRAMS / CH4 / 4-1-5.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-11-02  |  2.7 KB  |  90 lines

  1. VERSION 5.00
  2. Begin VB.Form frmAdd 
  3.    Caption         =   "Add Two Numbers"
  4.    ClientHeight    =   1695
  5.    ClientLeft      =   3300
  6.    ClientTop       =   3060
  7.    ClientWidth     =   2775
  8.    BeginProperty Font 
  9.       Name            =   "MS Sans Serif"
  10.       Size            =   8.25
  11.       Charset         =   0
  12.       Weight          =   700
  13.       Underline       =   0   'False
  14.       Italic          =   0   'False
  15.       Strikethrough   =   0   'False
  16.    EndProperty
  17.    LinkTopic       =   "Form1"
  18.    PaletteMode     =   1  'UseZOrder
  19.    ScaleHeight     =   1695
  20.    ScaleWidth      =   2775
  21.    Begin VB.PictureBox picResult 
  22.       AutoRedraw      =   -1  'True
  23.       Height          =   255
  24.       Left            =   120
  25.       ScaleHeight     =   195
  26.       ScaleWidth      =   2475
  27.       TabIndex        =   5
  28.       Top             =   1320
  29.       Width           =   2535
  30.    End
  31.    Begin VB.CommandButton cmdCompute 
  32.       Caption         =   "Compute Sum"
  33.       Height          =   375
  34.       Left            =   600
  35.       TabIndex        =   4
  36.       Top             =   840
  37.       Width           =   1575
  38.    End
  39.    Begin VB.TextBox txtSecondNum 
  40.       Height          =   285
  41.       Left            =   1680
  42.       TabIndex        =   1
  43.       Top             =   480
  44.       Width           =   975
  45.    End
  46.    Begin VB.TextBox txtFirstNum 
  47.       Height          =   285
  48.       Left            =   1680
  49.       TabIndex        =   0
  50.       Top             =   120
  51.       Width           =   975
  52.    End
  53.    Begin VB.Label lblSecondNum 
  54.       AutoSize        =   -1  'True
  55.       Caption         =   "Second Number"
  56.       Height          =   195
  57.       Left            =   240
  58.       TabIndex        =   3
  59.       Top             =   480
  60.       Width           =   1365
  61.    End
  62.    Begin VB.Label lblFirstNum 
  63.       AutoSize        =   -1  'True
  64.       Caption         =   "First Number"
  65.       Height          =   195
  66.       Left            =   480
  67.       TabIndex        =   2
  68.       Top             =   120
  69.       Width           =   1095
  70.       WordWrap        =   -1  'True
  71.    End
  72. Attribute VB_Name = "frmAdd"
  73. Attribute VB_GlobalNameSpace = False
  74. Attribute VB_Creatable = False
  75. Attribute VB_PredeclaredId = True
  76. Attribute VB_Exposed = False
  77. Private Sub cmdCompute_Click()
  78.   Dim x As Single, y As Single
  79.   'This program requests two numbers and
  80.   'displays the two numbers and their sum.
  81.   x = Val(txtFirstNum.Text)
  82.   y = Val(txtSecondNum.Text)
  83.   Call Add(x, y)
  84. End Sub
  85. Private Sub Add(num1 As Single, num2 As Single)
  86.   'Display numbers and their sum
  87.   picResult.Cls
  88.   picResult.Print "The sum of"; num1; "and"; num2; "is"; num1 + num2
  89. End Sub
  90.