Public Class frmDensities

  Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
    'Calculate the population densities of states
    Dim state As String, pop, area As Double
    Dim s As String, p, a As Double
    lstDensity.Items.Clear()
    state = "Hawaii"
    pop = 1275194
    area = 6471
    CalculateDensity(state, pop, area)
    lstDensity.Items.Add("")
    s = "Alaska"
    p = 663661
    a = 591000
    CalculateDensity(s, p, a)
  End Sub

  Sub CalculateDensity(ByVal state As String, _
                       ByVal pop As Double, ByVal area As Double)
    'The density (number of people per square mile)
    'will be displayed rounded to one decimal place
    Dim density As Double
    density = pop / area
    lstDensity.Items.Add("The density of " & state & " is")
    lstDensity.Items.Add(FormatNumber(density, 1) & " people per square mile.")
  End Sub

End Class
