Countdown Timer

how do i create a countdown timer

  • (2 Pages)
  • +
  • 1
  • 2

15 Replies - 49511 Views - Last Post: 23 June 2006 - 09:27 AM Rate Topic: -----

#1 magma79  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 20-June 06

Countdown Timer

Post icon  Posted 20 June 2006 - 10:52 AM

I am not by any means new to VB. I have been playing with and learning the language for awhile now. One personal project I have been working on is trying to create a countdown timer. I have not been able to figure out how to create a moving timer...i.e. when the timer starts you see the seconds, minutes, hours, etc. counting down. I have figured out how to create a snapshot / still timer. Any help would be appreciated.
Is This A Good Question/Topic? 0
  • +

Replies To: Countdown Timer

#2 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Countdown Timer

Posted 20 June 2006 - 11:27 AM

VB6 or VB.NET?
Was This Post Helpful? 0
  • +
  • -

#3 magma79  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 20-June 06

Re: Countdown Timer

Posted 20 June 2006 - 11:34 AM

View PostAmadeus, on 20 Jun, 2006 - 10:19 AM, said:

VB6 or VB.NET?


written in VB .NET -- i hate VB6... :music:
Was This Post Helpful? 0
  • +
  • -

#4 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: Countdown Timer

Posted 20 June 2006 - 12:48 PM

All you need to do is create a timer for one second, the rest is just decrementing numbers. There is a timer in the toolbox, just set its value to 1000 milliseconds which = 1 second.

ie. Create a timer that counts 1 second, in your display labels or textboxes you would start with the time that you are counting down from and subtract one from the seconds everytime it ticks, then after 60 seconds you would subtract 1 from the minutes.

So bottom line, you need one timer that counts a second at a time and the rest is just math by subracting 1 from each value.

This post has been edited by jayman9: 20 June 2006 - 12:52 PM

Was This Post Helpful? 0
  • +
  • -

#5 magma79  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 20-June 06

Re: Countdown Timer

Post icon  Posted 20 June 2006 - 02:05 PM

View Postjayman9, on 20 Jun, 2006 - 11:40 AM, said:

All you need to do is create a timer for one second, the rest is just decrementing numbers. There is a timer in the toolbox, just set its value to 1000 milliseconds which = 1 second.

ie. Create a timer that counts 1 second, in your display labels or textboxes you would start with the time that you are counting down from and subtract one from the seconds everytime it ticks, then after 60 seconds you would subtract 1 from the minutes.

So bottom line, you need one timer that counts a second at a time and the rest is just math by subracting 1 from each value.



Thanks for the help...however, I understand the concept, but how in the blazes would i actually write code to accomplish this feat...I have an idea of how to, but it doesn't seem to come out right while trying to code it out...HELP again...thanks.. :blink:
Was This Post Helpful? 0
  • +
  • -

#6 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: Countdown Timer

Posted 20 June 2006 - 03:45 PM

Post what code you have completed so far or zip up the project and upload to the forum and I will help guide you the rest of the way.
Was This Post Helpful? 0
  • +
  • -

#7 magma79  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 20-June 06

Re: Countdown Timer

Post icon  Posted 21 June 2006 - 08:32 AM

View Postjayman9, on 20 Jun, 2006 - 02:37 PM, said:

Post what code you have completed so far or zip up the project and upload to the forum and I will help guide you the rest of the way.



okay the whole project is zipped up...hope the comments are enough to explain what I am trying to do.....you should understand...the folder called MoviePosters needs to be copied to the C:\ drive or the program will not run for ya...thanks for all the help...

This post has been edited by magma79: 21 June 2006 - 08:47 AM

Was This Post Helpful? 0
  • +
  • -

#8 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: Countdown Timer

Posted 21 June 2006 - 08:41 AM

View Postmagma79, on 21 Jun, 2006 - 07:24 AM, said:

View Postjayman9, on 20 Jun, 2006 - 02:37 PM, said:

Post what code you have completed so far or zip up the project and upload to the forum and I will help guide you the rest of the way.



okay the whole project is zipped up...hope the comments are enough to explain what I am trying to do.....you should understand...the folder called MoviePosters needs to be copied to the C:\ drive or the program will not run for ya...thanks for all the help...


I think you forgot to upload the project. After you browse to the zip file, click the add this attachment link.
Was This Post Helpful? 0
  • +
  • -

#9 magma79  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 20-June 06

Re: Countdown Timer

Posted 21 June 2006 - 09:02 AM

View Postjayman9, on 21 Jun, 2006 - 07:33 AM, said:

View Postmagma79, on 21 Jun, 2006 - 07:24 AM, said:

View Postjayman9, on 20 Jun, 2006 - 02:37 PM, said:

Post what code you have completed so far or zip up the project and upload to the forum and I will help guide you the rest of the way.



okay the whole project is zipped up...hope the comments are enough to explain what I am trying to do.....you should understand...the folder called MoviePosters needs to be copied to the C:\ drive or the program will not run for ya...thanks for all the help...


I think you forgot to upload the project. After you browse to the zip file, click the add this attachment link.



sorry, i was afraid nothing happened...okay i'll try it again...

Attached File  BlockbusterTimer.zip (267.33K)
Number of downloads: 2098
Was This Post Helpful? 0
  • +
  • -

#10 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Countdown Timer

Posted 21 June 2006 - 10:56 AM

In the future, it may be more effective to upload the code only...in that manner, the whole community can benefit from the solution. Thanks! :)
Was This Post Helpful? 0
  • +
  • -

#11 magma79  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 20-June 06

Re: Countdown Timer

Post icon  Posted 21 June 2006 - 02:19 PM

View PostAmadeus, on 21 Jun, 2006 - 09:48 AM, said:

In the future, it may be more effective to upload the code only...in that manner, the whole community can benefit from the solution. Thanks! :)


Okay, here's the code.......

' This is a cool Hollywood Blockbuster Movie timer to show off movie posters, the countdown clock
' till the movie is out in theatres, the official release date when the movie will be out, and the
' name that the movie will have...this is version 2...enhanced versions to come...
'
' created by: Robert Pond
' copyright 2006
'
'
Option Strict Off
Option Explicit On
Imports VB = Microsoft.VisualBasic

Friend Class frmMain
Inherits System.Windows.Forms.Form

' create an array of the movie listings
Private pstrMovieList() As String = {"X-Men III", "Superman Returns", "Harry Potter 5", _
"Pirates of the Carribean 2", "Mi: iii", "The DaVinci Code", "Spiderman 3", "She's The Man", _
"Ice Age 2", "Transformers"}

' create an array of the official movie title
Private pstrMovieTitle() As String = {"X-Men: The Last Stand", "Superman Returns", _
"Harry Potter and the Order of the Phoenix", "Pirates of the Carribean: Curse of the Black Pearl", _
"Mission: Impossible III", "The DaVinci Code", "Spiderman 3", "She's The Man", "Ice Age: The Meltdown", _
"Transformers"}

' create an array of the movie release dates
Private pstrReleaseDate() As String = {"05-26-2006", "06-28-2006", "06-01-2007", "07-07-2006", "05-05-2006", _
"05-19-2006", "05-04-2007", "03-17-2006", "03-31-2006", "11-17-2006"}

' create a new time variable for all the countdown timers..(release date, hour of release time)
Private pdatX3 As New System.DateTime(2006, 5, 26, 10, 0, 0)
Private pdatSR As New System.DateTime(2006, 6, 27, 22, 0, 0)
Private pdatHP5 As New System.DateTime(2007, 6, 1, 10, 0, 0)
Private pdatP2 As New System.DateTime(2006, 7, 7, 10, 0, 0)
Private pdatMi3 As New System.DateTime(2006, 5, 5, 10, 0, 0)
Private pdatTDC As New System.DateTime(2006, 5, 19, 10, 0, 0)
Private pdatS3 As New System.DateTime(2007, 5, 4, 10, 0, 0)
Private pdatSTM As New System.DateTime(2006, 3, 17, 10, 0, 0)
Private pdatIA2 As New System.DateTime(2006, 3, 31, 10, 0, 0)
Private pdatT As New System.DateTime(2006, 11, 17, 10, 0, 0)
Private pdatCurrent As Date = Today.Now



Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub

Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim pintCount As Integer

' add movie titles to choose from to the combo list box
For pintCount = 0 To pstrMovieList.GetUpperBound(0)
cboMovieListing.Items.Add(pstrMovieList(pintCount))
Next

' clear initial label values
lblMovieTitle.Text = ""
lblReleaseDate.Text = ""
lblToday.Text = "Today is: " & Today.Now
picMoviePoster.Image = System.Drawing.Image.FromFile _
("C:\MoviePosters\blank.bmp")


End Sub

Private Sub cboMovieListing_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboMovieListing.SelectedIndexChanged
Dim mdatElapsed As System.TimeSpan
Dim mstrElapsed As String
Dim mintFound As Integer

' whatever movie is chosen, display the header in the label box above the timer boxes, and the theatre
' release date, and the movie poster....lblMovieTitle, lblReleaseDate, picMoviePoster...lblReleaseTime
Select Case cboMovieListing.Text
Case "Superman Returns"
lblMovieTitle.Text = pstrMovieTitle(1)
lblReleaseDate.Text = pstrReleaseDate(1)
lblToday.Text = "Today is: " & Today.Now
picMoviePoster.Image = System.Drawing.Image.FromFile _
("C:\MoviePosters\SupermanRtrns.jpg")

' create variables to hold countdown values and apply to the right labels
Dim msinRDays, msinRHours, msinRMinutes, msinRSeconds As Single
Dim msinDays As Single = 6
Dim msinHours As Single = 23
Dim msinMinutes As Single = 59
Dim msinSeconds As Single = 59

tmrCountdown.Start()

lblDays.Text = msinDays.ToString
lblHours.Text = msinHours.ToString
lblMinutes.Text = msinMinutes.ToString
lblSeconds.Text = msinSeconds.ToString



Case "X-Men III"
lblMovieTitle.Text = pstrMovieTitle(0)
lblReleaseDate.Text = pstrReleaseDate(0)
lblToday.Text = "Today is: " & Today.Now
picMoviePoster.Image = System.Drawing.Image.FromFile _
("C:\MoviePosters\x3.jpg")



Case "Harry Potter 5"
lblMovieTitle.Text = pstrMovieTitle(2)
lblReleaseDate.Text = pstrReleaseDate(2)
lblToday.Text = "Today is: " & Today.Now
picMoviePoster.Image = System.Drawing.Image.FromFile _
("C:\MoviePosters\NotAvailable.bmp")



Case "Pirates of the Carribean 2"
lblMovieTitle.Text = pstrMovieTitle(3)
lblReleaseDate.Text = pstrReleaseDate(3)
lblToday.Text = "Today is: " & Today.Now
picMoviePoster.Image = System.Drawing.Image.FromFile _
("C:\MoviePosters\pirates2.jpg")


Case "Mi: iii"
lblMovieTitle.Text = pstrMovieTitle(4)
lblReleaseDate.Text = pstrReleaseDate(4)
lblToday.Text = "Today is: " & Today.Now
picMoviePoster.Image = System.Drawing.Image.FromFile _
("C:\MoviePosters\mi3.jpg")



Case "The DaVinci Code"
lblMovieTitle.Text = pstrMovieTitle(5)
lblReleaseDate.Text = pstrReleaseDate(5)
lblToday.Text = "Today is: " & Today.Now
picMoviePoster.Image = System.Drawing.Image.FromFile _
("C:\MoviePosters\da_vinci.jpg")



Case "Spiderman 3"
lblMovieTitle.Text = pstrMovieTitle(6)
lblReleaseDate.Text = pstrReleaseDate(6)
lblToday.Text = "Today is: " & Today.Now
picMoviePoster.Image = System.Drawing.Image.FromFile _
("C:\MoviePosters\NotAvailable.bmp")



Case "She's The Man"
lblMovieTitle.Text = pstrMovieTitle(7)
lblReleaseDate.Text = pstrReleaseDate(7)
lblToday.Text = "Today is: " & Today.Now
picMoviePoster.Image = System.Drawing.Image.FromFile _
("C:\MoviePosters\Shes_the_man.bmp")



Case "Ice Age 2"
lblMovieTitle.Text = pstrMovieTitle(8)
lblReleaseDate.Text = pstrReleaseDate(8)
lblToday.Text = "Today is: " & Today.Now
picMoviePoster.Image = System.Drawing.Image.FromFile _
("C:\MoviePosters\iceage2.jpg")



Case "Transformers"
lblMovieTitle.Text = pstrMovieTitle(9)
lblReleaseDate.Text = pstrReleaseDate(9)
lblToday.Text = "Today is: " & Today.Now
picMoviePoster.Image = System.Drawing.Image.FromFile _
("C:\MoviePosters\NotAvailable.bmp")



Case Else
lblMovieTitle.Text = "No movie currently selected!"
lblReleaseDate.Text = ""
lblToday.Text = "Today is: " & Today.Now
picMoviePoster.Image = Nothing
lblReleaseTime.Text = ""

End Select

End Sub

Private Sub tmrCountdown_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmrCountdown.Tick
' need to add the code necessary to show the timer clicking
' so I can effectively have an active countdown timer in the
' countdown labels...
End Sub
End Class

This post has been edited by magma79: 21 June 2006 - 02:23 PM

Was This Post Helpful? 0
  • +
  • -

#12 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: Countdown Timer

Posted 21 June 2006 - 04:26 PM

I found this little tidbit for you to read. It will give you a pretty good idea how to create a countdown timer.
Was This Post Helpful? 0
  • +
  • -

#13 magma79  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 20-June 06

Re: Countdown Timer

Post icon  Posted 22 June 2006 - 11:04 AM

View Postjayman9, on 21 Jun, 2006 - 03:18 PM, said:

I found this little tidbit for you to read. It will give you a pretty good idea how to create a countdown timer.


:blink: Thanks, but because of the way my newest revision code is written, the above example won't work...I have another problem with my newest version of the above program. Below is a small snippet of the program.

*******
Private Sub cboMovieListing_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboMovieListing.SelectedIndexChanged
Dim mdatElapsed As System.TimeSpan
Dim mstrElapsed As String
Dim mintFound As Integer

' whatever movie is chosen, display the header in the label box above the timer boxes, and the theatre
' release date, and the movie poster....lblMovieTitle, lblReleaseDate, picMoviePoster...lblReleaseTime
Select Case cboMovieListing.Text

Case "Superman Returns"
lblMovieTitle.Text = pstrMovieTitle(1)
lblReleaseDate.Text = pstrReleaseDate(1)
lblToday.Text = "Today is: " & Today.Now
picMoviePoster.Image = System.Drawing.Image.FromFile _
("C:\Program Files\RDP\SupermanRtrns.jpg")

mdatElapsed = pdatSR.Subtract(pdatCurrent)
mstrElapsed = System.Convert.ToString(mdatElapsed)

If mintFound = mstrElapsed.IndexOf("-") Then
lblReleaseTime.Text = "Hello, check your local theatre listings!"
Else
lblReleaseTime.Text = mdatElapsed.ToString
End If *********

Okay, the System.TimeSpan function seems to work really well with subtracting the current time from set time. However, I have the program written to when you choose a movie from a drop down box, various labels get populated with information, including the remaining time between the current time and the release time...however, if the same movie is selected more than once, the Elapsed Time will not refresh with time that has changed between the first time the movie was selected and the succeeding times selected. HOW would I get the remaining time to always refresh and show the real time left and not the time left from the first time the movie was chosen...????
Was This Post Helpful? 0
  • +
  • -

#14 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: Countdown Timer

Posted 22 June 2006 - 03:02 PM

Quote

Okay, the System.TimeSpan function seems to work really well with subtracting the current time from set time. However, I have the program written to when you choose a movie from a drop down box, various labels get populated with information, including the remaining time between the current time and the release time...however, if the same movie is selected more than once, the Elapsed Time will not refresh with time that has changed between the first time the movie was selected and the succeeding times selected. HOW would I get the remaining time to always refresh and show the real time left and not the time left from the first time the movie was chosen...????


Using the SelectedIndexChanged method you cannot. Since selecting the same item in the combo box does not change the index, it will not fire off your method.

However, I think you are heading down the wrong path. Here is the direction you need to go. I will only post the sections of code that I have modified but I think you will get the idea.

First you need to declare two global variables to hold the release date and one to contain the timespan between today and release date.
	Private pdatIA2 As New System.DateTime(2006, 3, 31, 10, 0, 0)
	Private pdatT As New System.DateTime(2006, 11, 17, 10, 0, 0)
	Private pdatCurrent As Date = Today.Now

	'added a global date variable to hold the current item release date
	'added a global TimeSpan to contain the difference between Today and Release Day
	Dim releaseDate As Date
	Dim remainTime As TimeSpan



Now inside each case is where you assign the values to the 2 global variables realeaseDate and remainTime. This way it will always count down from the last selected movie. I commented the two lines I added to each case shown here, you need to repeat how I did it for the remaining cases.

   Private Sub cboMovieListing_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboMovieListing.SelectedIndexChanged
		Dim mdatElapsed As System.TimeSpan
		Dim mstrElapsed As String
		Dim mintFound As Integer
		'start timer here
		tmrCountdown.Start()

		' whatever movie is chosen, display the header in the label box above the timer boxes, and the theatre
		' release date, and the movie poster....lblMovieTitle, lblReleaseDate, picMoviePoster...lblReleaseTime
		Select Case cboMovieListing.Text

			Case "Superman Returns"
				lblMovieTitle.Text = pstrMovieTitle(1)
				lblReleaseDate.Text = pstrReleaseDate(1)
				lblToday.Text = "Today is: " & Today.Now
				picMoviePoster.Image = System.Drawing.Image.FromFile _
				("C:\MoviePosters\SupermanRtrns.jpg")

				'assign release date to global variable so we can work with it in other methods
				releaseDate = pdatSR
				'determine the remaining time till movie is released and store in global variable
				remainTime = Today.Now.Subtract(releaseDate)

				mdatElapsed = pdatSR.Subtract(pdatCurrent)
				mstrElapsed = System.Convert.ToString(mdatElapsed)

				If mintFound = mstrElapsed.IndexOf("-") Then
					lblReleaseTime.Text = "Hello, check your local theatre listings!"
				Else
					lblReleaseTime.Text = mdatElapsed.ToString
				End If



			Case "X-Men III"
				lblMovieTitle.Text = pstrMovieTitle(0)
				lblReleaseDate.Text = pstrReleaseDate(0)
				lblToday.Text = "Today is: " & Today.Now

				'assign release date to global variable so we can work with it in other methods
				releaseDate = pdatX3
				'determine the remaining time till movie is released and store in global variable
				remainTime = Today.Now.Subtract(releaseDate)

				picMoviePoster.Image = System.Drawing.Image.FromFile _
				("C:\MoviePosters\x3.jpg")



And last but not least, you need to let the Timer tick method handle displaying and changing the countdown timer. The if statement is to keep the countdown timer from displaying anything until you select something from the combo box. Otherwise it would start counting down right away from what I am not sure, but it is needed.

	Private Sub tmrCountdown_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmrCountdown.Tick

		If Me.cboMovieListing.SelectedIndex <> -1 Then
			'reset the remain time from the current time
			remainTime = releaseDate.Subtract(Today.Now)
			Me.lblDays.Text = remainTime.Days.ToString
			Me.lblHours.Text = remainTime.Hours.ToString
			Me.lblMinutes.Text = remainTime.Minutes.ToString
			Me.lblSeconds.Text = remainTime.Seconds.ToString
		End If

	End Sub



This will get your timer working, however you will find that you still need to handle when the release date is past. Right now it just shows a negative time since it is past the release date.


Let me know if I can help you further.
Was This Post Helpful? 0
  • +
  • -

#15 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: Countdown Timer

Posted 22 June 2006 - 03:52 PM

If I could make a suggestion as to a more efficent way of utilizing your code that would also minimize the amount of changes you would need to make each time you modify the movies listed in your combo box.

Why not store all your dates in the array you had already created for just that purpose(just make it a date array instead of a string array), rather than creating a variable to hold the date for each movie. Then you can just reference the date using one variable instead of 10 different variables.

And instead of using the names of the movies as the conditions for your select statement, why not just use the SelectedIndex of the combo box. This will eliminate the need for you to modify your code in 10 different places every time you update your movie list with new movies.

Now whenever you update your movie listing, all you need to do is modify the values stored in your arrays and not worry about anywhere else in your code.

Global variables:
' create an array of the movie listings
	Private pstrMovieList() As String = {"X-Men III", "Superman Returns", "Harry Potter 5", _
	"Pirates of the Carribean 2", "Mi: iii", "The DaVinci Code", "Spiderman 3", "She's The Man", _
	"Ice Age 2", "Transformers"}

	' create an array of the official movie title
	Private pstrMovieTitle() As String = {"X-Men: The Last Stand", "Superman Returns", _
	"Harry Potter and the Order of the Phoenix", "Pirates of the Carribean: Curse of the Black Pearl", _
	"Mission: Impossible III", "The DaVinci Code", "Spiderman 3", "She's The Man", "Ice Age: The Meltdown", _
	"Transformers"}

	' create an array of the movie release dates
	Private pstrReleaseDate() As Date = {New System.DateTime(2006, 5, 26, 10, 0, 0), _
										New System.DateTime(2006, 6, 27, 22, 0, 0), _
										New System.DateTime(2007, 6, 1, 10, 0, 0), _
										New System.DateTime(2006, 7, 7, 10, 0, 0), _
										New System.DateTime(2006, 5, 5, 10, 0, 0), _
										New System.DateTime(2006, 5, 19, 10, 0, 0), _
										New System.DateTime(2007, 5, 4, 10, 0, 0), _
										New System.DateTime(2006, 3, 17, 10, 0, 0), _
										New System.DateTime(2006, 3, 31, 10, 0, 0), _
										New System.DateTime(2006, 11, 17, 10, 0, 0)}
 
	Private pdatCurrent As Date = Today.Now

	'added a global date variable to hold the current item release date
	'added a global TimeSpan to contain the difference between Today and Release Day
	Dim releaseDate As Date
	Dim remainTime As TimeSpan



Modified Select statment:
Select Case cboMovieListing.SelectedIndex

			Case 0
				lblMovieTitle.Text = pstrMovieTitle(0)
				lblReleaseDate.Text = pstrReleaseDate(0).Date
				lblToday.Text = "Today is: " & Today.Now

				'assign release date to global variable so we can work with it in other methods
				releaseDate = pstrReleaseDate(0)
				'determine the remaining time till movie is released and store in global variable
				remainTime = Today.Now.Subtract(releaseDate)

				picMoviePoster.Image = System.Drawing.Image.FromFile _
				("C:\MoviePosters\x3.jpg")


			Case 1
				lblMovieTitle.Text = pstrMovieTitle(1)
				lblReleaseDate.Text = pstrReleaseDate(1).Date
				lblToday.Text = "Today is: " & Today.Now
				picMoviePoster.Image = System.Drawing.Image.FromFile _
				("C:\MoviePosters\SupermanRtrns.jpg")

				'assign release date to global variable so we can work with it in other methods
				releaseDate = pstrReleaseDate(1)
				'determine the remaining time till movie is released and store in global variable
				remainTime = Today.Now.Subtract(releaseDate)

				mdatElapsed = pstrReleaseDate(1).Subtract(pdatCurrent)
				mstrElapsed = System.Convert.ToString(mdatElapsed)

				If mintFound = mstrElapsed.IndexOf("-") Then
					lblReleaseTime.Text = "Hello, check your local theatre listings!"
				Else
					lblReleaseTime.Text = mdatElapsed.ToString
				End If



Again just a suggestion. :D
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2