Hi All:
I have this code below that uses an open common dialog box to dispay 5 horse pictures.
Does anyone have the code to display the pictures on the Form only by passing the horse picture names as parameters when I call the subprocedure in the mnuViewNext and mnuViewPrevious event handlers?
I set only 2 horse names because I will add 3 names in the add horses event handler later
Thanks
Public Class Form1
Inherits System.Windows.Forms.Form
Dim gstrShortList(4) As String
Dim gintCurrentRecord As Integer
Dim gintNumberOfHorses(4) As Integer
Private Sub DisplayPicture(ByVal intRecord As Integer)
If intRecord < 0 Then
intRecord = 0
End If
If gintNumberOfHorses.IndexOf(gintNumberOfHorses, 0.0) <> -1 Then
If intRecord > gintNumberOfHorses.IndexOf(gintNumberOfHorses, 0.0) - 1 Then
intRecord = gintNumberOfHorses.IndexOf(gintNumberOfHorses, 0.0) - 1
End If
End If
gintCurrentRecord = intRecord
PictureBox1.Image = Image.FromFile(gstrShortList(gintCurrentRecord))
End Sub
Private Function CountHorses() As Integer
Dim intTotalHorses As Integer
Dim intValue As Integer
For Each intValue In gintNumberOfHorses
intTotalHorses += gintNumberOfHorses(intValue)
Next
Return intTotalHorses
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
gstrShortList(0) = "C:\Horse Arabian.jpg"
gstrShortList(1) = "C:\Horse Mustang.jpg"
gintNumberOfHorses(0) = 0
gintNumberOfHorses(1) = 1
End Sub
Private Sub mnuFileHorsePictures_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileHorsePictures.Click
With OpenFileDialog1
With OpenFileDialog1
.Title = "Choose a Picture to Display"
.InitialDirectory = "C:\My HORSES & NICE HORSES Files"
.CheckFileExists = True
.Filter = "Picture files (*.jpg)/*.jpg"
.ShowDialog()
PictureBox1.Image = Image.FromFile(.FileName)
stbInfo.Text = Convert.ToString(CountHorses())
End With
End With
End Sub
Private Sub mnuFileExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileExit.Click
Close()
End Sub
Private Sub mnuViewNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuViewNext.Click
DisplayPicture(gintCurrentRecord + 1)
End Sub
Private Sub mnuViewPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuViewPrevious.Click
DisplayPicture(gintCurrentRecord - 1)
End Sub
End Class
:)