Sunteți pe pagina 1din 7

Programming Code

Public Class Form1

Private Sub CloseToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles CloseToolStripMenuItem.Click
Try

Application.Exit()
Catch ex As Exception
MessageBox.Show("Error.")
End Try
End Sub

Private Sub CrudeBirthRateToolStripMenuItem_Click(ByVal sender As System.Object, ByVal


e As System.EventArgs) Handles CrudeBirthRateToolStripMenuItem.Click
Try

Dim intBirths As Integer


intBirths = InputBox("Enter the number of births per day")

Dim dblCrudeBirthRate As Double


dblCrudeBirthRate = ((intBirths * 365) / 1000)

lblOutput.Text = "The crude birth rate is " & dblCrudeBirthRate & " per 1000 individuals"
Catch ex As Exception
MessageBox.Show("Error.")
End Try

End Sub

Private Sub CrudeDeathRateToolStripMenuItem_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles CrudeDeathRateToolStripMenuItem.Click
Try
Dim intDeaths As Integer
intDeaths = InputBox("Enter the number of deaths per day")

Dim dblCrudeDeathRate As Double


dblCrudeDeathRate = ((intDeaths * 365) / 1000)
lblOutput.Text = "The crude death rate is " & dblCrudeDeathRate & " per 1000
individuals"
Catch ex As Exception
MessageBox.Show("Error.")
End Try
End Sub

Private Sub ActualBirthRateToolStripMenuItem_Click(ByVal sender As System.Object, ByVal


e As System.EventArgs) Handles ActualBirthRateToolStripMenuItem.Click
Try
Dim intBirths As Integer
intBirths = InputBox("Enter the number of births per day")

Dim intPopulation As Integer


intPopulation = InputBox("Enter the population number")

Dim dblActualBirthRate As Double


dblActualBirthRate = ((intBirths * 365) / intPopulation) * 100

Dim dblOverall As Double


dblOverall = Math.Round(dblActualBirthRate, 3)

lblOutput.Text = "The actual birth rate is " & dblOverall & " %."
Catch ex As Exception
MessageBox.Show("Error.")
End Try
End Sub

Private Sub ActualDeathRateToolStripMenuItem_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles ActualDeathRateToolStripMenuItem.Click
Try
Dim intDeaths As Integer
intDeaths = InputBox("Enter the number of deaths per day")

Dim intPopulation As Integer


intPopulation = InputBox("Enter the population number")

Dim dblActualDeathRate As Double


dblActualDeathRate = ((intDeaths * 365) / intPopulation) * 100

Dim dblOverall As Double


dblOverall = Math.Round(dblActualDeathRate, 3)
lblOutput.Text = "The actual death rate is " & dblOverall & " %."

Catch ex As Exception
MessageBox.Show("Error.")
End Try
End Sub

Private Sub PopulationDensityToolStripMenuItem_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles PopulationDensityToolStripMenuItem.Click
Try
Dim intPopulation As Integer
Dim dblArea As Double
Dim dblPopDensity As Double

intPopulation = InputBox("Enter the population number")


dblArea = InputBox("Enter the area in square miles")

dblPopDensity = intPopulation / (dblArea)

Dim dblOverall As Double


dblOverall = Math.Round(dblPopDensity, 3)
lblOutput.Text = "The population density is " & dblOverall & " square miles."
Catch ex As Exception
MessageBox.Show("Error.")
End Try
End Sub

Private Sub DoublingTimeOfAPopulationToolStripMenuItem_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
DoublingTimeOfAPopulationToolStripMenuItem.Click
Try
Dim dblGrowthRate As Double
Dim intBirths As Integer = InputBox("Enter the number of births per day")

Dim dblCrudeBirthRate As Double


dblCrudeBirthRate = ((intBirths * 365) / 1000)
Dim dblCrudeDeathRate As Double
Dim intDeaths As Integer = InputBox("Enter the number of deaths per day")
dblCrudeDeathRate = ((intDeaths * 365) / 1000)

Dim intImmigration As Integer = InputBox("Enter immigration number per day")


Dim intEmmigration As Integer = InputBox("Enter emmigration number per day")
dblGrowthRate = (((dblCrudeBirthRate + ((intImmigration * 365) / 1000)) -
(dblCrudeDeathRate + ((intEmmigration * 365) / 1000))) / 10)
Dim dblDoublingTime As Double

dblDoublingTime = 70 / dblGrowthRate

Dim dblOverall As Double

dblOverall = Math.Round(dblDoublingTime, 3)

lblOutput.Text = "The doubling time is " & dblOverall & " years."
Catch ex As Exception
MessageBox.Show("Error.")
End Try
End Sub

Private Sub NetPopulationGrowthRateToolStripMenuItem_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
NetPopulationGrowthRateToolStripMenuItem.Click
Try
Dim intBirths As Integer = InputBox("Enter number of births per day")
Dim intDeaths As Integer = InputBox("Enter number of deaths per day")
Dim intPopulation As Integer = InputBox("Enter population number")
Dim dblNetPopGrowthRate As Double

dblNetPopGrowthRate = ((((intBirths * 365) - (intDeaths * 365)) / intPopulation)) * 100

Dim dblOverall As Double


dblOverall = Math.Round(dblNetPopGrowthRate, 5)
lblOutput.Text = "The net population growth rate is " & dblOverall & " %."
Catch ex As Exception
MessageBox.Show("Error.")
End Try
End Sub

Private Sub PopulationInTheFutureToolStripMenuItem_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
PopulationInTheFutureToolStripMenuItem.Click
Try
Dim intBirths As Integer = InputBox("Enter number of births per day")
Dim intDeaths As Integer = InputBox("Enter number of deaths per day")
Dim intImmigration As Integer = InputBox("Enter immigration number per day")
Dim intEmmigration As Integer = InputBox("Enter emmigration number per day")
Dim intPopulation As Integer = InputBox("Enter population number")
Dim dblNatality As Double
Dim dblMortality As Double

dblNatality = ((intPopulation / 1000) * intBirths)


dblMortality = ((intPopulation / 1000) * intDeaths)

Dim intPopFuture As Integer

intPopFuture = intPopulation + (dblNatality - dblMortality) + (((intImmigration * 365) /


1000) - ((intEmmigration * 365) / 1000))

lblOutput.Text = "The population in the future is " & intPopFuture & " people."
Catch ex As Exception
MessageBox.Show("Error.")
End Try
End Sub

Private Sub NationalPopulationGrowthRateToolStripMenuItem1_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
NationalPopulationGrowthRateToolStripMenuItem1.Click
Try
Dim intBirths As Integer

Dim dblNationalGrowthRate As Double

intBirths = InputBox("Enter the number of births per day")

Dim dblCrudeBirthRate As Double


dblCrudeBirthRate = ((intBirths * 365) / 1000)

Dim dblCrudeDeathRate As Double


Dim intDeaths As Integer = InputBox("Enter the number of deaths per day")
dblCrudeDeathRate = ((intDeaths * 365) / 1000)

Dim intImmigration As Integer = InputBox("Enter immigration number per day")


Dim intEmmigration As Integer = InputBox("Enter emmigration number per day")
Dim intImm As Integer = (intImmigration * 365) / 1000
Dim intEmm As Integer = (intEmmigration * 365) / 1000
dblNationalGrowthRate = (((dblCrudeBirthRate + intImm) - (dblCrudeDeathRate +
intEmm)) / 10)

Dim dblOverall As Double


dblOverall = Math.Round(dblNationalGrowthRate, 3)
lblOutput.Text = "The national population growth rate is " & dblOverall & " %."
Catch ex As Exception
MessageBox.Show("Error.")
End Try
End Sub

Private Sub GlobalPopulationGrowthRateToolStripMenuItem_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
GlobalPopulationGrowthRateToolStripMenuItem.Click
Try
Dim intBirths As Integer

Dim dblGlobalGrowthRate As Double

intBirths = InputBox("Enter the number of births per day")

Dim dblCrudeBirthRate As Double


dblCrudeBirthRate = ((intBirths * 365) / 1000)

Dim dblCrudeDeathRate As Double


Dim intDeaths As Integer = InputBox("Enter the number of deaths per day")
dblCrudeDeathRate = ((intDeaths * 365) / 1000)

dblGlobalGrowthRate = ((dblCrudeBirthRate - dblCrudeDeathRate) / 10)

Dim dblOverall As Double


dblOverall = Math.Round(dblGlobalGrowthRate, 3)

lblOutput.Text = "The global growth rate is " & dblOverall & " %."
Catch ex As Exception
MessageBox.Show("Error.")
End Try
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load

End Sub
End Class

S-ar putea să vă placă și