•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the VB.NET section within the Software Development category of DaniWeb, a massive community of 402,860 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,926 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our VB.NET advertiser: Programming Forums
Views: 9026 | Replies: 0
![]() |
•
•
Join Date: Jun 2004
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
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
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
![]() |
•
•
•
•
•
•
•
•
DaniWeb VB.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
.net apple browser cd choose computer crack dell development download drm explorer france ie 7 install internet leopard license linux mac microsoft mobile news office open operating operating system os parliament pc phishing photo prompt security server software source system tiger ubuntu unix upgrade virus vista volume web windows windows update windows vista xp
- Need Help Regarding MultiThreading (ASP.NET)
- About Windows Forms C# .net 2003 (C#)
- Arranging Windows Forms (C#)
- pointers to windows forms (C)
- Windows Forms Question (C#)
- Using Windows XP Visual Styles with Controls on Windows Forms (VB.NET)
- Forms Authorization/ Authentication using asp .net and vb .net (ASP.NET)
- Controlling windows scroll (VB.NET)
- Do I need .net framework just for windows 98 hotmail and messenger?? (Windows 9x / Me)
Other Threads in the VB.NET Forum
- Previous Thread: How do I limit text char in Combo box?
- Next Thread: MySQL - ASP.NET - Issues....


Linear Mode