I am having a small problem with my program... Right now I have a text document with name, file location, imdb rating, ect. I had it working last night to view the text and show all the info in labels. This is still working. The problem I am having is with cmdPlay:

Private Sub cmdplay_Click()
Shell "C:\Program Files\Winamp\winamp.exe " & strlocation
End Sub

it was working last night to play each movie file... It still plays the movie file but it only plays one movie... no matter which one is selected it only plays that one movie. I have a database of 4 movies and it keeps playing the last one. The full program code is below and is as follows:

Option Explicit
Public strlocation As String
Private Sub cbotitle_Click()
Dim strmovie As String, strimdb As String, strper As String, stryear As String, strgen1 As String, strgen2 As String, strdirect As String, strlead1 As String, strlead2 As String, strlead3 As String

Open "C:\Movies\Data Base\Movie.txt" For Input As #2
Do While Not EOF(2)
Input #2, strmovie, strlocation, strimdb, strper, stryear, strgen1, strgen2, strdirect, strlead1, strlead2, strlead3
If strmovie = cbotitle.Text Then
lblimdb.Caption = "IMDb Rating:" & vbCrLf & strimdb & "/10"
lblpersonal.Caption = "Personal Rating:" & vbCrLf & strper & "/10"
lblyear.Caption = "Year:" & vbCrLf & stryear
lblgen1.Caption = "Main Genre:" & vbCrLf & strgen1
lblgen2.Caption = "Second Genre:" & vbCrLf & strgen2
lbldirect.Caption = "Director: " & strdirect
lbllead1.Caption = "Leading Actor: " & strlead1
lbllead2.Caption = "Secondary Actor: " & strlead2
lbllead3.Caption = "Supporting Actor: " & strlead3
End If
Loop
Close #2
End Sub

Private Sub cmdexit_Click()
Unload frmShow
frmMain.Visible = True
End Sub


Private Sub cmdplay_Click()
Shell "C:\Program Files\Winamp\winamp.exe " & strlocation
End Sub

Private Sub Form_Load()
Call refreshinterface
End Sub

Sub refreshinterface()
Dim strmovie As String, strimdb As String, strper As String, stryear As String, strgen1 As String, strgen2 As String, strdirect As String, strlead1 As String, strlead2 As String, strlead3 As String
cbotitle.Clear
Open "C:\Movies\Data Base\Movie.txt" For Input As #2
Do While Not EOF(2)
Input #2, strmovie, strlocation, strimdb, strper, stryear, strgen1, strgen2, strdirect, strlead1, strlead2, strlead3
cbotitle.AddItem strmovie
Loop
Close #2
End Sub

Try making your variables into array's.

try:
declare your variables like this,

Dim strmovie(100) As String, strimdb(100) As String, strper(100) As String, stryear(100) As String, strgen1(100) As String, strgen2(100) As String, strdirect(100) As String, strlead1(100) As String, strlead2(100) As String, strlead3(100) As String
Dim selection

then change this


Private Sub cbotitle_Click()
a=0
Do While Not EOF(2)
Input #2, strmovie(a), strlocation(a), strimdb(a), strper(a), stryear(a), strgen1(a), strgen2(a), strdirect(a), strlead1(a), strlead2(a), strlead3(a)
If strmovie(a) = cbotitle.Text Then
selection = a
lblimdb.Caption = "IMDb Rating:" & vbCrLf & strimdb(a) & "/10"
lblpersonal.Caption = "Personal Rating:" & vbCrLf & strper(a) & "/10"
lblyear.Caption = "Year:" & vbCrLf & stryear(a)
lblgen1.Caption = "Main Genre:" & vbCrLf & strgen1(a)
lblgen2.Caption = "Second Genre:" & vbCrLf & strgen2(a)
lbldirect.Caption = "Director: " & strdirect(a)
lbllead1.Caption = "Leading Actor: " & strlead1(a)
lbllead2.Caption = "Secondary Actor: " & strlead2(a)
lbllead3.Caption = "Supporting Actor: " & strlead3(a)
End If
a=a+1
Loop
Close #2
End Sub

Private Sub cmdplay_Click()
Shell "C:\Program Files\Winamp\winamp.exe " & strlocation(selection)
End Sub

Sub refreshinterface()
a=0
cbotitle.Clear
Open "C:\Movies\Data Base\Movie.txt" For Input As #2
Do While Not EOF(2)
Input #2, strmovie(a), strlocation(a), strimdb(a), strper(a), stryear(a), strgen1(a), strgen2(a), strdirect(a), strlead1(a), strlead2(a), strlead3(a)
cbotitle.AddItem strmovie(a)
a=a+1
Loop
Close #2
End Sub


Hope this helps,
Mike

Comments
Helped alot

Thank you so much. I was thinking about using arrays but i never really learned how to use them. Thank you for helping

This article has been dead for over six months. Start a new discussion instead.