kahaj 0 Junior Poster

I can't figure out how to subtract the running total from 10. I also can't figure out how to make the time remaining label have a value when the form loads. Any tips on this would be SO much appreciated.

Imports System.IO

Public Class atvRecords

   'Public var declaration
   Private timeRemaining As Decimal = 10
   Private lifetime As Decimal = 11
   Private timeLeft As List(Of Double)

   Private Sub atvRecords_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
   Handles MyBase.Load

      'if time left less than 2, messagebox
      If Val(lifetimeHrsOutputLbl.Text) <= 2 And Val(lifetimeHrsOutputLbl.Text) > 1 Then
         MessageBox.Show("Two hours or less of ride time remains before an oil change is needed.", _
         "Oil change needed soon.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
      End If

      'if time left less than 1, messagebox
      If Val(lifetimeHrsOutputLbl.Text) <= 1 And Val(lifetimeHrsOutputLbl.Text) Then
         MessageBox.Show("One hour or less of ride time remains before an oil change is needed.", _
         "Oil change needed soon.", MessageBoxButtons.OK, MessageBoxIcon.Warning)
      End If

      'if time left less than 0, messagebox
      If Val(lifetimeHrsOutputLbl.Text) <= 0 Then
         MessageBox.Show("WARNING: Do NOT ride any more until an oil change is performed!", _
         "OIL CHANGE NEEDED IMMEDIATELY!", MessageBoxButtons.OK, MessageBoxIcon.Stop)
      End If

   End Sub

   Public Function SaveTextToFile(ByVal strData As String, _
   ByVal FullPath As String, Optional ByVal ErrInfo As String = "") As Boolean

      Dim bAns As Boolean = False
      Dim objReader As StreamWriter

      Try
         objReader = New StreamWriter(FullPath)
         objReader.Write(strData)
         objReader.Close()
         bAns = True
      Catch Ex As Exception
         ErrInfo = Ex.Message
      End Try
      Return bAns
   End Function

   Private Sub submitBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
   Handles submitBtn.Click

      'clear time spent label
      timeSpentTxt.Text = ""


      'write to file for Running Tally

      Dim runningTally As List(Of Double)
      Dim todaysTime As Double = Val(timeSpentTxt.Text) = 0
      runningTally.Add(todaysTime)
      Dim tempTotal As String = 0

      For Each Item As Double In runningTally
         timeRemaining -= Item
         tempTotal += Item & ";"
      Next

      SaveTextToFile(tempTotal, _
            "C:\Documents and Settings\All Users\Documents\College-C\IT\VB.Net\Assignments\Semester Project\ATV Records\runningTally.txt")


      'calculate time remaining
      timeRemaining = 10 - tempTotal


      'calculate lifetime hours
      lifetimeHrsOutputLbl.Text = lifetime
      lifetime += tempTotal

   End Sub

   Private Sub resetBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
   Handles resetBtn.Click

      'runningTally = 0
      timeRemaining = 10

   End Sub
End Class
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.