Herman the Fly
You don't need to use arrays in this program.
In order to add an entry to a list box during runtime, simply use the Items.Add method. For example, to add the value 15 to the list box lstFred, use the statement lstFred.Items.Add(15)
To force the most recent addition to a list box to be displayed, you need the index of the last item added. You can obtain this from the value returned by Items.Add. For example,
Dim newIndex As Integer
newIndex = lstFred.Items.Add(15)
To highlight that most recent addition, use the setSelected method. For example,
For more details on the list box, go here.
Here is the delay routine:
Private Sub getDelay(ByVal delayInSec As Double)
You can call it using the statement Call getDelay(400)
Here's some info on the random number generator.
Read more details here.
* This statement
may require that you include this line before any other lines of code in
your program. Imports
Why do I keep getting the same
random number for Herman and poison?
The Herman Hints above mention that you might need to "reseed" the random number generator to get a different number. I included a line like Thread.Sleep(4) to reseed it, and the modified version also includes a static variable that tracks what the last random number was, and keeps regenerating numbers until it gets a different number. I used a loop to handle that.
Why aren't my labels for Herman and poison updated until after Herman dies?
That's an oddity that popped up in the .Net version of VB. You can refresh the label if you need to with a statement like lblInitHerman.Refresh(). You'll need to do that for each label that you want to change.
Dr. Beard's structure chart for the program can be found here....You do not have to follow it directly, but it will give you a good idea about modularization. More on structure charts here.