Problem creating Slideshow... Help!

mattkw80

Well-known member
Joined
Jan 3, 2008
Messages
49
Location
Ontario, Canada
Programming Experience
Beginner
Hey guys, putting together a simple training program in which I need to show the user text and pictures. I want them to be able to hit a "next button" which will step through the text and pictures, like a slide show. All the "data" is hard coded in the program, so I'm not using a database, or xml, or anything like that.

Basically I've been going like this:

form1.textbox1.text = "Here is my first sentence"
form1.picbox1.image = (firstpicture.jpg)
messagebox.show ("next")
form1.textbox1.text = "Here is the second sentence."
form1.picbox1.image = (secondpicture.jpg)
messagebox.show ("next")

etc. etc. etc.


Is there any easy way to lump all of my text and picture file names into one, and seprate them by // marks, so that when the user hits a next button, it will go to the next section?

ie:

form1.textbox1.text = "Here is my first sentence // Here is the second sentence."
form1.picbox1.image = (firstpicture.jpg//secondpicture.jpg)

So, when the user hit next, it would show the next text and the next picture file name.

Is there a better way to do this?


Basically.... I'd like one block of text, seperated by // marks, and a list of picture.jpg files, to go with each //. Anybody know a better way to do this?
 
I would suggest something like this.

You should add a Button(NextButton) to your form. And then add the following code tot the code of the form.

VB.NET:
Private Viewing as integer = -1
Private Texts() as string = {"Here is my first sentence", "Here is the second sentence."}
Private Images() as string = {"firstpicture.jpg", "secondpicture.jpg"}

Private Sub NextButton_Click(ByVal sender as System.Object, ByVal e as System.EventArgs) Handles NextButton.Click
   'Check if last text/image has been reached
   If Texts.count = Viewing + 1 Then Exit Sub
   'Increase viewing by one
   Viewing += 1
   'Set text and image
   Me.TextBox1.Text = Texts(Viewing)
   Me.Picturebox1.LoadAsync(Images(Viewing)
End Sub

You should also run this sub or raise the click event on load to directly show the first text and image.
 
Back
Top