Re: Animation with 5 picture boxes using VB.NET
Example
Code:
Public Class Form1
Private SequenceArray() as String
Private ArrayIndex as Integer=0
Private Sub StartSequence()
'Read file and populate array here
'Also make sure arrayindex is set to 0 at this point
End Sub
End Class
Your timer code looks ok except the timer3.enabled=true line is useless and should be deleted from that block of code.
Re: Animation with 5 picture boxes using VB.NET
For reading the file and populating the array. you would use streamreader, then use the readline method to read one line into a regular string var. Then you use the split method on that resulting string to populate the array with the elements from the line.
From here on the array is the key.
look at the example I gave you in the other thread for using split to populate an array, in this case instead of readtoend we use readline and instead of splitting on vbCR you would use "," as your split delimiter
Re: Animation with 5 picture boxes using VB.NET
Thanks DataMiser! I followed your instructions but it still doesn't work :(
I still get the same error at this line:
Code:
Select Case Val(SequenceArray(ArrayIndex))
saying object not referenced
Code:
Option Strict Off
Option Explicit On
Friend Class frmDigIn_Aha
Inherits System.Windows.Forms.Form
Private myStopwatch As New Stopwatch
Private startTime As DateTime
Private OnGoingGame As Boolean = False
Private SequenceArray() As String
Private ArrayIndex As Integer = 0
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
startTime = Trim(Format(Now, "hh:mm:ss tt"))
StartTimeBox.Text = startTime
My.Computer.Audio.Play("C:\Aha_TakeOnMe.wav", AudioPlayMode.Background)
Timer1.Start()
myStopwatch.Start()
Dim AllData() As String = System.IO.File.ReadAllLines("C:\AhaImageText.txt")
ArrayIndex = 0
End Sub
Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
PictureBox0.Visible = True
PictureBox1.Visible = False
PictureBox2.Visible = False
PictureBox3.Visible = False
PictureBox4.Visible = False
Select Case Val(SequenceArray(ArrayIndex))
Case 1
PictureBox1.Visible = True
Case 2
PictureBox2.Visible = True
Case 3
PictureBox3.Visible = True
Case 4
PictureBox4.Visible = True
End Select
ArrayIndex += 1
End Sub
Re: Animation with 5 picture boxes using VB.NET
I do not see anyplace where you are populating the array.
Re: Animation with 5 picture boxes using VB.NET
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
startTime = Trim(Format(Now, "hh:mm:ss tt"))
StartTimeBox.Text = startTime
My.Computer.Audio.Play("C:\Aha_TakeOnMe.wav", AudioPlayMode.Background)
Timer1.Start()
myStopwatch.Start()
Dim DanceSteps as New System.IO.StreamReader("C:\AhaImageText.txt")
Dim DanceStepsText as string=DanceSteps.ReadLine()
DanceSteps.Close
SequenceArray=DanceStepsText.Split(",")
ArrayIndex = 0
End Sub
Re: Animation with 5 picture boxes using VB.NET
THANK YOU SO MUCH! I truly appreciate all your help and expertise! From having ZERO knowledge in vb.net to creating a dancing game and actually understanding what each line does is truly remarkable! God bless you!
Re: Animation with 5 picture boxes using VB.NET
I see your timer sub is called timer3 but in your code I see you starting timer1 and stopwatch but no timer 3. Where is this timer started?
Re: Animation with 5 picture boxes using VB.NET
You're welcome :)
Glad I could help
Re: Animation with 5 picture boxes using VB.NET
I have 4 timers in my code, timer 3 was suppose to be for the pictureboxes
i have timer3 enabled in another subroutine :)
Re: Animation with 5 picture boxes using VB.NET
Remember you will need to stop the timer when you reach the last item in the array or you will get an index out of bounds error when it passes the last item.