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-2-6.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-11-02  |  1.7 KB  |  60 lines

  1. VERSION 5.00
  2. Begin VB.Form frm4_2_6 
  3.    Caption         =   "Form-level Variables"
  4.    ClientHeight    =   2100
  5.    ClientLeft      =   1095
  6.    ClientTop       =   1485
  7.    ClientWidth     =   3270
  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     =   2100
  20.    ScaleWidth      =   3270
  21.    Begin VB.PictureBox picResults 
  22.       Height          =   855
  23.       Left            =   360
  24.       ScaleHeight     =   795
  25.       ScaleWidth      =   2355
  26.       TabIndex        =   1
  27.       Top             =   960
  28.       Width           =   2415
  29.    End
  30.    Begin VB.CommandButton cmdDisplay 
  31.       Caption         =   "Display Results"
  32.       Height          =   495
  33.       Left            =   480
  34.       TabIndex        =   0
  35.       Top             =   240
  36.       Width           =   2175
  37.    End
  38. Attribute VB_Name = "frm4_2_6"
  39. Attribute VB_GlobalNameSpace = False
  40. Attribute VB_Creatable = False
  41. Attribute VB_PredeclaredId = True
  42. Attribute VB_Exposed = False
  43. Dim num1 As Single, num2 As Single
  44. Private Sub cmdDisplay_Click()
  45.   'Display the sum of two numbers
  46.   num1 = 2
  47.   num2 = 3
  48.   picResults.Cls
  49.   Call AddAndIncrement
  50.   picResults.Print
  51.   picResults.Print "num1 = "; num1
  52.   picResults.Print "num2 = "; num2
  53. End Sub
  54. Private Sub AddAndIncrement()
  55.   'Display numbers and their sum
  56.   picResults.Print "The sum of"; num1; "and"; num2; "is"; num1 + num2
  57.   num1 = num1 + 1
  58.   num2 = num2 + 1
  59. End Sub
  60.