Public Class frmCountry

  Structure Nation
    Dim name As String
    Dim continent As String
    Dim population As Double  'in millions
    Dim area As Double        'in square miles
  End Structure

  Dim country As Nation       'class-level variable

  Private Sub frmCountry_Load(ByVal sender As System.Object,
                              ByVal e As System.EventArgs) Handles MyBase.Load
    'Assign values to country's member variables
    Dim line As String = "China,Asia,1332.5,3696100"
    Dim data() As String = line.Split(","c)
    country.name = data(0)
    country.continent = data(1)
    country.population = CDbl(data(2))
    country.area = CDbl(data(3))
  End Sub

  Private Sub btnDisplay_Click(ByVal sender As System.Object,
                               ByVal e As System.EventArgs) Handles btnDisplay.Click
    'Display data in text boxes
    txtName.Text = country.name
    txtContinent.Text = country.continent
    txtPop.Text = FormatNumber(1000000 * country.population, 0)
    txtArea.Text = FormatNumber(country.area, 0) & " square miles"
    txtDensity.Text = FormatNumber(1000000 * country.population / country.area) &
                      " people per square mile"
  End Sub

End Class
