simple arithmetic problem

I am an absolute beginner and have been requested develope a programme which gives the time in hours and minutes to cook meat by weight.

I have sucessfully done this for all weights but am stuck if the weight is only one kilo up to and less than 2 kilos. If the weight is one kilo then the time is 30 minutes, which shows as 30 hours and in the kilo slot!

i.e. If Kilo < 2 then

Kilo = (Kilo * 1000\ 33.33)

Else: Kilo = (Kilo * 1000\ 33.33 \60)

If Grams < 1000 Then

Grams = (Grams \ 33.33)

MsgBox(Kilo & "" & "Hour/s" & Grams & " Minutes")

I wondered if there was a way to have the one kilo result added to the gram result and then convert this into hours and minutes - not just minutes. Have tried numberFormat, pi and all sorts but am stumped. Your help would be greatly appreciated.



Answer this question

simple arithmetic problem

  • Steven Ulbrich

    Many thanks. I now have it sorted! Great to get some help.


  • spm

    Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
    Dim Meat As Integer
    Dim Time, Hr, Mn As Decimal
    Meat = TrackBar1.Value
    If Meat > 10 And Meat < 1500 Then
    Mn = 30
    Hr = 0
    End If
    If Meat > 1500 And Meat < 2000 Then
    Mn = 45
    Hr = 0
    End If
    If Meat > 2000 And Meat < 2500 Then
    Mn = 0
    Hr = 1
    End If
    If Meat > 2500 And Meat < 2500 Then
    Mn = 15
    Hr = 1
    End If
    If Meat > 2500 Then
    Mn = 30
    Hr = 1
    End If
    TextBox1.Text = "" & Meat / 1000 & " kg of Meat needs " & Hr & " hours " & " and " & Mn & " Mins. to cook at 180 degrees celsius. "


    End Sub



  • RebEl

    Many thanks, I am grateful for your help.
  • Spencer Harris

    For the hour and minute part, just do minutes and then use the modulus to turn it into hours.

    Eg:

    If minutes >= 60 Then

    newMinutes = minutes % 60

    hours = (minutes - newMinutes) / 60

    End If



  • simple arithmetic problem