Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
1.86/5 (3 votes)
See more:
I am trying like this but not showing correct output Please help me..

VB
Private timeLeft As Integer
  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


      BindQuestion(1)
      TimerInfo.Totaltime = DateTime.Now.AddMinutes(120).ToString()
      Timer1.Start()

      'Bind 1st question by default


  End Sub



VB
Private Sub Timer1_Tick_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
       If 0 > DateTime.Compare(DateTime.Now, DateTime.Parse(TimerInfo.Totaltime)) Then
           timeLabel.Text = "Number of Minutes Left: " & Convert.ToString(Convert.ToDateTime(TimerInfo.Totaltime).Subtract(DateTime.Now).TotalMinutes)
       End If
Posted
Updated 5-Oct-14 23:44pm
v2
Comments
Pheonyx 6-Oct-14 5:58am    
Firstly, what is the correct output? and secondly, what output are you getting?
We cannot see your screen or know what you are expecting so you have to tell us.

1 solution

Use a TimeSpan. This will be much easier.

VB
Dim myTimeSpan as TimeSpan
myTimeSpan = TimerInfo.TotalTime - DateTime.Now
msgbox(myTimeSpan.TotalMinutes())


That is based on TimerInfo.TotalTime being the time of expiry.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900