home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form frmStates
- Caption = "State Demographics"
- ClientHeight = 1620
- ClientLeft = 1128
- ClientTop = 1656
- ClientWidth = 4944
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 7.8
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H80000008&
- LinkTopic = "Form1"
- PaletteMode = 1 'UseZOrder
- ScaleHeight = 1620
- ScaleWidth = 4944
- Begin VB.CommandButton cmdDisplay
- Caption = "Display Demographics"
- Default = -1 'True
- Height = 495
- Left = 840
- TabIndex = 1
- Top = 240
- Width = 3375
- End
- Begin VB.PictureBox picDensity
- Height = 495
- Left = 120
- ScaleHeight = 444
- ScaleWidth = 4644
- TabIndex = 0
- Top = 960
- Width = 4695
- End
- Attribute VB_Name = "frmStates"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Private Sub cmdDisplay_Click()
- Dim state As String, pop As Single, area As Single
- Dim s As String, p As Single, a As Single
- 'Calculate the population densities of states
- picDensity.Cls
- Open App.Path & "\DEMOGRAP.TXT" For Input As #1
- Input #1, state, pop, area
- Call CalculateDensity(state, pop, area)
- Input #1, s, p, a
- Call CalculateDensity(s, p, a)
- Close #1
- End Sub
- Private Sub CalculateDensity(state As String, pop As Single, area As Single)
- Dim rawDensity As Single, density As Single
- 'The density (number of people per square mile)
- 'will be rounded to a whole number
- rawDensity = pop / area
- density = Round(rawDensity)
- picDensity.Print "The density of "; state; " is"; density;
- picDensity.Print "people per square mile."
- End Sub
-