Program Flow

  • Thread starter Thread starter freeman.matt
  • Start date Start date
F

freeman.matt

So I'm writing an interface for my GPS unit and I've come up with a few
questions about how VB works. This is my first experience with a
'visual' programming language, and it's a little differient than the
console style I'm used to.

At this point, my interface works to a degree. It was built in VB .NET
2003 and it has a windows form on it with a button and a text field.
Whenever you hit the button, the form reads in the data from the GPS,
displays it in the appropriate blanks, and then writes that data to a
logfile. The form then does nothing until you hit the button again at
which point it updates the data and marks a new point in the log.

While this does accomplish my original objective (creation of a
logfile), I would like the data fields in the form to update themselves
in real time. The GPS spits out a data stream every second, and while
I do not need all that data logged, it would be useful to have a real
time readout of measurement accuracy. If I could begin to update the
data in the fields as soon as the application starts, then the button
would only need to be pressed when I want to create an entry in the
logfile.

In pseudo code, this is what I'm trying to do...
\\\
Start
Init Serial Port
Repeat
Read GPS Data
Update GPS Data in Form
If Button Pressed
Output data to logfile
Until Close
End
///

I'm a little confused as to how to do this in VB, so any pointers would
be very appreciated.

Thanks in advance.

-Matt
 
I'm a little confused as to how to do this in VB, so any pointers would
be very appreciated.

Drag and drop a "Timer" component onto your form. Set the timer tick
property to around 2000 (2 seconds) and then handle the "Tick" event. The
timer will fire the event once every two seconds. In the event you can read
your GPS and update the text box.
 
Robinson said:
Drag and drop a "Timer" component onto your form. Set the timer tick
property to around 2000 (2 seconds) and then handle the "Tick" event. The
timer will fire the event once every two seconds. In the event you can read
your GPS and update the text box.

Thanks a lot... worked like a charm!

-Matt
 
and now ...

create a second timer ... run it every 10 seconds (or some other realistic
interval) to write information to your log file ... that way you do not rely
on the user to press a button each time they want to create a log entry ...
 
Back
Top