Back to Examples
Public Class JacobMorris

  Private Sub btnCompute_Click(sender As Object, e As EventArgs) Handles btnCompute.Click

    Dim intCups As Integer = 0
    Dim intCaffeine As Integer = 0
    Dim intHours As Integer = 0
    Dim intCaffeineTemp As Integer = 0

    If IsNumeric(txtCups.Text) Then

      intCups = txtCups.Text
      intCaffeine = intCups * 130
      intCaffeineTemp = intCaffeine

      Do
        intCaffeineTemp = intCaffeineTemp – (intCaffeineTemp * 0.13)
        intHours = intHours + 1

      Loop Until intCaffeineTemp <= 65

      txtHours.Text = intHours
      ‘Computes the number of hours it will take until the body has 65mg or less of caffeine.
      intCaffeineTemp = intCaffeine
      intHours = 0
      ‘resets variables to prepare for the next computation.

      Do

        intCaffeineTemp = intCaffeineTemp – (intCaffeineTemp * 0.13)
        intHours = intHours + 1

      Loop Until intHours = 24

      txtDayone.Text = intCaffeineTemp
      ‘Computes the amount of caffeine in the body 24 hours after consumption.
      intCaffeineTemp = intCaffeine
      intHours = 0
      ‘resets variables to prepare for the next computation.

      Do

        intCaffeineTemp = 130 + (intCaffeineTemp – (intCaffeineTemp * 0.13))
        intHours = intHours + 1

      Loop Until intHours = 24

      txtEachhour.Text = intCaffeineTemp
      ‘Computes the amount of caffeine in the body after 24 hours if the user drinks a cup every hour.

    Else

      MessageBox.Show(“Please enter a valid number of cups.”)

    End If

    ‘Makes sure the user entered a valid number of cups

  End Sub

End Class
Back to Examples

Startup Discount
Small Business?
Contact us for an Enormous Discount!