I am trying to design a movie review program in V.B. and I continue to get errors where ever images are concerned.
I am fairly new at this and don't really understand what goes in the client and what goes in the original vb program that I wrote.
Please help me in some way. thank you very much. I have been working at this for days and unfortunatly have not made too much progress lateley.
thank you very much,
Darci
Public Class critiqueStreet
Private clients(0 To 6) As client 'client object
Private position As Integer = 0 'current movie
Private imageNum As Integer
Private Sub critiqueStreet_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim count As Integer
'create array of movie information
'Movie Data
Dim titles As String() = New String() {"PS I Love You", "Juno", "Once Were Warriors", "10 Items Or Less", "The Weatherman", "The Gambler", "Walk The Line"}
Dim genre As String() = New String() {"Drama", "Comedy", "Drama", "Comedy", "Drama", "Western", "Drama"}
Dim rating As Integer() = New Integer() {"9", "1", "2", "3", "1", "3", "0"} 'current movie rating
Dim year As String() = New String() {"2007", "2007", "1991", "1993", "2005", "1978", "2005"}
'loop and create 10 client ofjects
For count = 0 To clients.GetUpperBound(0)
'create new object and store into client array
clients(count) = New client(titles(count), genre(count), rating(count), year(count))
Displayratings() 'display first movie in the box (hopefully)
Next
End Sub
Function BuildPathName() As Integer
Dim output As Integer = imageNum
'Input string was not in a correct format.
'output &= ".png" 'add the extension
PictureBox.Visible = True
If imageNum = 1 Then
PictureBox.Image = Image.FromFile("\images\bomb")
output = imageNum
End If
'PictureBox.Image = Image.FromFile("\images\bomb")
' output = output.ToString(0, System.Environment.CurrentDirectory & "\images\bomb")
Return output
End Function
Private Sub nextButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nextButton.Click
Displayratings()
position += 1 'increment movies
'retrieve the rating image
'imageNum = (imageNum + 1) Mod 3 'image num cycles from 0 - 2
Dim output As Integer = imageNum
'PictureBox.Image = Image.FromFile("\images\image") & imageNum & ".png"
'there will be no if statement you will just call the images from the getter.
If imageNum = 1 Then
PictureBox.Image = Image.FromFile("\images\thumbdown.png")
ElseIf imageNum = 2 Then
PictureBox.Image = Image.FromFile("\images\thumbup.png")
ElseIf imageNum = 3 Then
PictureBox.Image = Image.FromFile("\images\star.png")
ElseIf imageNum = 0 Then
PictureBox.Image = Image.FromFile("\images\bomb.PNG")
End If
'does this go here or in the client file??????yes
'If output < 0 Then
' rating = 0
' ElseIf output > 3 Then
' rating = 3
'End If
'if position is last(top) object
If position > clients.GetUpperBound(0) Then
position = 0 'set to first position in array
DisplayInformation() 'display info
Else
DisplayInformation()
End If
End Sub 'next button
Private Sub previousButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles previousButton.Click
position -= 1 'decrement position
'if position is last(bottom) object
If position < 0 Then
'set to last position in array
position = clients.GetUpperBound(0)
DisplayInformation()
Else
DisplayInformation() 'display info
End If
End Sub 'previous button
'display the images in the picture box
'Sub Display images()
'retreive the actual rating from the movie
' rating = options(
'display information
Private Sub DisplayInformation()
'use position as index for each object
titleTextBox.Text = clients(position).titles
strGenre.Text = clients(position).genre
ratingTextBox.Text = Convert.ToString(clients(position).ratings)
yearTextBox.Text = Convert.ToString(clients(position).year)
End Sub 'display info
'In order to display the correct image add the .png extension to the rating image and assign it to the image property of the picRatingImage picturebox using the FromFile function of the Image object, and the System.Environment.CurrentDirectory covered in your text and at the end of the exam
Sub Displayratings()
'get images full path name
Dim path As String = BuildPathName()
' PictureBox.Image = Image.FromFile("\images\") 'display image
End Sub
End Class 'movie review form
Here is the client program too......
Public Class client Private m_titles As String Private m_genre As String Private m_ratings As Integer Private m_year As Integer Private imageNum As Integer = -1 Public Sub New(ByVal title As String, ByVal genres As String, ByVal rating As Integer, ByVal years As Integer) titles = title genre = genres ratings = rating year = years End Sub Public Property titles() As String Set(ByVal titles As String) m_titles = titles End Set Get Return m_titles End Get End Property Public Property genre() As String Set(ByVal genre As String) m_genre = genre End Set Get Return m_genre End Get End Property Public Property ratings() As Integer Set(ByVal ratings As Integer) m_ratings = ratings imageNum = ratings End Set ' Set(ByVal imageNum As Integer) 'imageNum = ratings 'and input the If ratings < 0 then in the getter ' End Set Get Return m_ratings ' End Get 'set loops intratings loops '1. intRating can not be less than 0 or greater than 3. '2. Values less than 0 default to 0 '3. Values greater than 3 default to 3.. 'still need to complete this part. '4. When intRating is set, strRatingImage is also set based on the table below: ' Set(ByVal rating() As Integer) If ratings < 0 Then imageNum = 0 ElseIf ratings > 3 Then imageNum = 3 End If ' End Set ' Get Return imageNum End Get End Property Public Property year() As String Set(ByVal year As String) m_year = year End Set Get Return m_year End Get End Property End Class

New Topic/Question
Reply




MultiQuote





|