User Name Password Register
DaniWeb IT Discussion Community
All
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 456,526 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,805 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: 9666 | Replies: 0
Reply
Join Date: Jun 2004
Posts: 1
Reputation: VBRAY is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
VBRAY VBRAY is offline Offline
Newbie Poster

Help Displaying pictures on Windows Forms using subprocedures in VB.NET

  #1  
Aug 10th, 2004
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

AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb VB.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the VB.NET Forum

All times are GMT -4. The time now is 4:15 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC