Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2008 > Visual Basic 2008 Essentials
|
Visual Basic 2008 Essentials If you are new to Visual Basic programming with version 2008, this is the place to start your questions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2008 Essentials section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 13th, 2009, 01:11 PM
Authorized User
 
Join Date: Jun 2008
Posts: 33
Thanks: 2
Thanked 0 Times in 0 Posts
Default Create an array of time values?

I want to be able to click a button and start a timer that is just counting up. I then want to be able to create an array of numbers that are from the time values.

So for examle if I pressed start the timer would start counting 1 sec, 2 sec, 3 sec... and then an array would be created like t=(1,2,3...) but in what ever format it needs to be in for vb 2008.

Any ideas? This is probable very simple and I am just stupid.

I plan to make a plot of a value that I will be reading in to vb from a temperature gage. The plot will be time versus temperature. That is why
i want an array of time from the moment I press the button.

I hope this makes sense.
 
Old January 13th, 2009, 07:18 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Ummm...not to ask a dumb question, but why do you need the array???

If you have the start time and the end time (of the period where you are collecting the temperatures), isn't that all you need???

Then you just run a loop:
Code:
For sampleTime = startTime To endTime 
    ...plot one temperature value as Y value while using sampleTime as X value ...
Next
Or, if you really wanted the X values to start with zero, then just do:
Code:
For sampleTime = 0 To endTime-startTime+1
    ...plot one temperature value as Y value while using sampleTime as X value ...
Next
This assumes you keep the startTime and endTime values as integers, of course.

Finally...

SURELY you are storing the temperatures into an array while you are recording them, no?

So why not just
Code:
For sampleTime = 0 To UBound(temperaturesArray) 
    x = sampleTime
    y = temperaturesArray(sampleTime)
    ... plot x and y ...
Next
It just seems utterly pointless to keep around an array that is nothing but monotonically increasing integers.
 
Old February 7th, 2009, 05:15 AM
Authorized User
 
Join Date: Dec 2008
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by sanderson View Post
I want to be able to click a button and start a timer that is just counting up.
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Enabled = True
Quote:
Originally Posted by sanderson View Post
I then want to be able to create an array of numbers that are from the time values.
Code:
Dim arrTimes() as DateTime
Quote:
Originally Posted by sanderson View Post
So for examle if I pressed start the timer would start counting 1 sec, 2 sec, 3 sec... and then an array would be created like t=(1,2,3...) but in what ever format it needs to be in for vb 2008.
Code:
Dim tics as Integer = 0
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
arrTimes(tics) = now()
tics += 1
End Sub


Any ideas? This is probable very simple and I am just stupid.

I plan to make a plot of a value that I will be reading in to vb from a temperature gage. The plot will be time versus temperature. That is why
i want an array of time from the moment I press the button.

I hope this makes sense.[/QUOTE]





Similar Threads
Thread Thread Starter Forum Replies Last Post
Store time into Array derekl ASP.NET 1.0 and 1.1 Basics 3 December 18th, 2006 09:41 AM
Create array from database Lofa PHP Databases 1 November 14th, 2006 07:56 PM
Adding the values within an array Dave_Richards Beginning PHP 0 November 8th, 2006 04:34 PM
How do I add up values in an array? Lucy Classic ASP Basics 6 May 31st, 2005 05:26 AM
Passing php array values to javascript array gkrishna Pro PHP 0 November 6th, 2004 03:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.