Create an application that will predict the approximate size of a population of organisms. The user should select or enter the starting number of organisms in a combo box, enter the average daily population increase(as percentage) in a text box, and select or enter the number of days the organisms will be left to multiply in another combo box. For example, assume the user enters the following values:
Starting number of organisms: 2
Average daily increase: 30%
number of days to multiply: 10
So MY question is this: i created my text box, and my two combo boxes with some choices for the user OR the user can type their own into the combo box's text box. So i wrote the code ( or at least i thought i did ) so that the population could be calculated by multiplying the number of organisms by the average daily increase ( i left the percentage part out for now). What i get on my list box is ALL zeros...We are supposed to use some type of loop that uses the number of days to multiply as the counter. So if the user puts in 4, it will calculate it for day 1, then for day 2, then for day 3 and finally for day 4 and then it will stop. i used a for...next loop. Here is what code i have:
Public Class Form1
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
'closes the form.
Me.Close()
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
'clears the list box.
Output.Items.Clear()
'clears the combo boxes
cboOrganisms.SelectedIndex = -1
cboOrganisms.Text = String.Empty
cboDays.SelectedIndex = -1
cboDays.Text = String.Empty
'clears the text box
intAverage.Clear()
End Sub
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
'variables declared.
Dim intAverage As Integer
Dim intCount As Integer
Dim intTotal As Integer
'calculates the population
For intCount = 1 To cboDays.Text
intTotal = cboOrganisms.Text * intAverage
Output.Items.Add(intTotal)
Next
End Sub
End Class
Thanks for taking the time to read this long post.

New Topic/Question
Reply



MultiQuote




|