VB Snippet

Project - Movie Collection

This project uses text files to store the necessary information in a manner similar to a relational database.

Note: this project was completed at the end of May 2003, so any hidden errors should surface within a couple of months.

(minor bug1 -15 June- Add/Edit Star Names is supposed to replace any spaces in the last name with "_" eg Danny De Vito would be Danny De_Vito. This is necessary for the autocomplete boxes at the right of the Star Name comboboxes, which searches for the final " " in the full name. The star name comboboxes list the stars alphabetically, by last name. Code below and zip files amended)

(minor bug2 - 22 August - one-word star names, saved incorrectly causing error when program next opened - fixed. Problem caused by treating name as 'FirstName' (more natural) and storing name as 'LastName' (for sorting). Also edit movie did not refresh - fixed. Code below and zip files amended)

(minor bug3 - 6 June 2004 - editing movie format VHS to DVD, or vice versa, the data was saved in the genre1 field instead of format field - fixed. Code below and zip files amended)

The files are
    movies.txt   (ID,title,star1 ID,star2 ID,star3 ID,star4 ID,genre1 ID,genre2 ID,genre3 ID,year,format)
    stars.txt      (ID,first name, last name)
    genres.txt   (ID,genre)
    nextIDs.txt (nextMovieID,nextStarID,nextGenreID)

These files are automatically created (in the program directory) when starting the program for the first time.

An example of a record in movies.txt is (the record for the screenshot)

    136|Casablanca|10|320|321|145|19|33|82|1940 - 1949|DVD

view screenshot

download source files, the exe file (as a zip), or copy/paste code below
(if you download, the exe file, ensure you do a virus scan, and you may(?) need the VB runtime files)

VB Code

Start a new project with Form1

save the form as Form1
save the project as any name
close vb
copy Form1.frm as Form1OLD.frm
with notepad, open Form1.frm
replace the entire contents of Form1.frm with the following (saves building the GUI)
change the caption (on line 5, or in the vb IDE) to whatever you want
save Form1.frm
open vb, and you should have the above screenshot, but without data
start entering data

 

VERSION 5.00
Begin VB.Form Form1
   BackColor       =   &H80000005&
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Michael & Olga's Movie Collection"
   ClientHeight    =   7620
   ClientLeft      =   45
   ClientTop       =   285
   ClientWidth     =   10905
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   ScaleHeight     =   7620
   ScaleWidth      =   10905
   StartUpPosition =   2  'CenterScreen
   Begin VB.ComboBox cboHidden
      Height          =   360
      Left            =   3360
      Sorted          =   -1  'True
      TabIndex        =   52
      Text            =   "Combo1"
      Top             =   6240
      Visible         =   0   'False
      Width           =   855
   End
   Begin VB.TextBox txtGenre3
      Height          =   285
      Left            =   7440
      TabIndex        =   51
      Top             =   3840
      Width           =   375
   End
   Begin VB.TextBox txtGenre2
      Height          =   285
      Left            =   7440
      TabIndex        =   50
      Top             =   3360
      Width           =   375
   End
   Begin VB.TextBox txtGenre1
      Height          =   285
      Left            =   7440
      TabIndex        =   49
      Top             =   2880
      Width           =   375
   End
   Begin VB.TextBox txtStar4
      Height          =   285
      Left            =   7440
      TabIndex        =   48
      Top             =   2400
      Width           =   375
   End
   Begin VB.TextBox txtStar3
      Height          =   285
      Left            =   7440
      TabIndex        =   47
      Top             =   1920
      Width           =   375
   End
   Begin VB.TextBox txtStar2
      Height          =   285
      Left            =   7440
      TabIndex        =   46
      Top             =   1440
      Width           =   375
   End
   Begin VB.TextBox txtStar1
      Height          =   285
      Left            =   7440
      TabIndex        =   45
      Top             =   960
      Width           =   375
   End
   Begin VB.TextBox txtAutoSelect
      Height          =   375
      Left            =   120
      TabIndex        =   44
      Top             =   7200
      Width           =   2415
   End
   Begin VB.CommandButton btnEditMovie
      Caption         =   "Edit"
      Height          =   375
      Left            =   4560
      TabIndex        =   43
      Top             =   4800
      Width           =   495
   End
   Begin VB.CommandButton btnEditGenre
      Caption         =   "Edit"
      Height          =   375
      Left            =   4560
      TabIndex        =   42
      Top             =   7080
      Width           =   495
   End
   Begin VB.CommandButton btnEditStar
      Caption         =   "Edit"
      Height          =   375
      Left            =   4560
      TabIndex        =   41
      Top             =   5520
      Width           =   495
   End
   Begin VB.ComboBox cboFormat
      Height          =   315
      Left            =   6600
      Style           =   2  'Dropdown List
      TabIndex        =   40
      Top             =   4320
      Width           =   855
   End
   Begin VB.ComboBox cboYear
      Height          =   315
      Left            =   4080
      Style           =   2  'Dropdown List
      TabIndex        =   39
      Top             =   4320
      Width           =   1575
   End
   Begin VB.ComboBox cboGenre3
      Height          =   315
      Left            =   4080
      Sorted          =   -1  'True
      Style           =   2  'Dropdown List
      TabIndex        =   38
      Top             =   3840
      Width           =   3375
   End
   Begin VB.ComboBox cboGenre2
      Height          =   315
      Left            =   4080
      Sorted          =   -1  'True
      Style           =   2  'Dropdown List
      TabIndex        =   37
      Top             =   3360
      Width           =   3375
   End
   Begin VB.ComboBox cboGenre1
      Height          =   315
      Left            =   4080
      Sorted          =   -1  'True
      Style           =   2  'Dropdown List
      TabIndex        =   36
      Top             =   2880
      Width           =   3375
   End
   Begin VB.ComboBox cboStar4
      Height          =   315
      Left            =   4080
      Style           =   2  'Dropdown List
      TabIndex        =   35
      Top             =   2400
      Width           =   3375
   End
   Begin VB.ComboBox cboStar3
      Height          =   315
      Left            =   4080
      Style           =   2  'Dropdown List
      TabIndex        =   34
      Top             =   1920
      Width           =   3375
   End
   Begin VB.ComboBox cboStar2
      Height          =   315
      Left            =   4080
      Style           =   2  'Dropdown List
      TabIndex        =   33
      Top             =   1440
      Width           =   3375
   End
   Begin VB.ComboBox cboStar1
      Height          =   315
      Left            =   4080
      Style           =   2  'Dropdown List
      TabIndex        =   32
      Top             =   960
      Width           =   3375
   End
   Begin VB.CommandButton btnClear
      Caption         =   "Clear"
      Height          =   375
      Left            =   5160
      TabIndex        =   27
      Top             =   4800
      Width           =   2295
   End
   Begin VB.TextBox txtAddGenre
      Height          =   375
      Left            =   5160
      TabIndex        =   23
      Top             =   7080
      Width           =   2295
   End
   Begin VB.TextBox txtLastName
      Height          =   375
      Left            =   5160
      TabIndex        =   22
      Top             =   6240
      Width           =   2295
   End
   Begin VB.TextBox txtFirstName
      Height          =   375
      Left            =   5160
      TabIndex        =   21
      Top             =   5520
      Width           =   2295
   End
   Begin VB.CommandButton btnShowList
      Caption         =   "Show List"
      Height          =   255
      Left            =   8640
      TabIndex        =   20
      Top             =   1200
      Width           =   1455
   End
   Begin VB.CommandButton btnAddGenre
      Caption         =   "Add Genre"
      Height          =   375
      Left            =   3360
      TabIndex        =   9
      Top             =   7080
      Width           =   1095
   End
   Begin VB.CommandButton btnAddStar
      Caption         =   "Add Star"
      Height          =   375
      Left            =   3240
      TabIndex        =   8
      Top             =   5520
      Width           =   1215
   End
   Begin VB.CommandButton btnAddMovie
      Caption         =   "Add Movie"
      Height          =   375
      Left            =   3240
      TabIndex        =   7
      Top             =   4800
      Width           =   1215
   End
   Begin VB.TextBox txtTitle
      Height          =   525
      Left            =   4080
      MultiLine       =   -1  'True
      TabIndex        =   6
      Top             =   240
      Width           =   3375
   End
   Begin VB.ListBox lstShowCollection
      Height          =   5580
      Left            =   7920
      Sorted          =   -1  'True
      TabIndex        =   5
      Top             =   1800
      Width           =   2895
   End
   Begin VB.Frame fraCollection
      BackColor       =   &H80000005&
      Caption         =   "Show Collections By"
      Height          =   975
      Left            =   7920
      TabIndex        =   2
      Top             =   120
      Width           =   2895
      Begin VB.OptionButton optListDecade
         BackColor       =   &H80000005&
         Caption         =   "Decade"
         Height          =   195
         Left            =   1200
         TabIndex        =   31
         Top             =   600
         Width           =   1575
      End
      Begin VB.OptionButton optListDVD
         BackColor       =   &H80000005&
         Caption         =   "DVD"
         Height          =   195
         Left            =   1200
         TabIndex        =   28
         Top             =   240
         Width           =   1575
      End
      Begin VB.OptionButton optListGenre
         BackColor       =   &H80000005&
         Caption         =   "Genre"
         Height          =   195
         Left            =   120
         TabIndex        =   4
         Top             =   600
         Width           =   975
      End
      Begin VB.OptionButton optListStar
         BackColor       =   &H80000005&
         Caption         =   "Star"
         Height          =   255
         Left            =   120
         TabIndex        =   3
         Top             =   240
         Width           =   975
      End
   End
   Begin VB.ListBox lstMovies
      Height          =   6300
      Left            =   120
      Sorted          =   -1  'True
      TabIndex        =   0
      Top             =   840
      Width           =   3015
   End
   Begin VB.Label Label1
      BackColor       =   &H80000005&
      Caption         =   "Search"
      Height          =   255
      Left            =   2640
      TabIndex        =   53
      Top             =   7320
      Width           =   615
   End
   Begin VB.Label lblCollectionCount
      BackColor       =   &H80000005&
      Height          =   255
      Left            =   8400
      TabIndex        =   30
      Top             =   1560
      Width           =   2175
   End
   Begin VB.Label lblShowDetails
      BackColor       =   &H80000005&
      Caption         =   "Select Movie to show details"
      Height          =   255
      Left            =   120
      TabIndex        =   29
      Top             =   600
      Width           =   2175
   End
   Begin VB.Label lblAddGenre
      BackColor       =   &H80000005&
      Caption         =   "New Classification:"
      Height          =   255
      Left            =   5160
      TabIndex        =   26
      Top             =   6840
      Width           =   2055
   End
   Begin VB.Label lblAddLastName
      BackColor       =   &H80000005&
      Caption         =   "Last Name:"
      Height          =   255
      Left            =   5160
      TabIndex        =   25
      Top             =   6000
      Width           =   1335
   End
   Begin VB.Label lblAddFirstName
      BackColor       =   &H80000005&
      Caption         =   "First Name/s:"
      Height          =   255
      Left            =   5160
      TabIndex        =   24
      Top             =   5280
      Width           =   1575
   End
   Begin VB.Label lblFormat
      BackColor       =   &H80000005&
      Caption         =   "VHS/DVD:"
      Height          =   255
      Left            =   5760
      TabIndex        =   19
      Top             =   4440
      Width           =   855
   End
   Begin VB.Label lblYear
      BackColor       =   &H80000005&
      Caption         =   "Year:"
      Height          =   255
      Left            =   3360
      TabIndex        =   18
      Top             =   4440
      Width           =   615
   End
   Begin VB.Label lblGenre3
      BackColor       =   &H80000005&
      Caption         =   "Genre:"
      Height          =   255
      Left            =   3360
      TabIndex        =   17
      Top             =   3960
      Width           =   615
   End
   Begin VB.Label lblGenre2
      BackColor       =   &H80000005&
      Caption         =   "Genre:"
      Height          =   255
      Left            =   3360
      TabIndex        =   16
      Top             =   3480
      Width           =   615
   End
   Begin VB.Label lblGenre1
      BackColor       =   &H80000005&
      Caption         =   "Genre:"
      Height          =   255
      Left            =   3360
      TabIndex        =   15
      Top             =   3000
      Width           =   615
   End
   Begin VB.Label lblStar4
      BackColor       =   &H80000005&
      Caption         =   "Co-Star:"
      Height          =   255
      Left            =   3360
      TabIndex        =   14
      Top             =   2520
      Width           =   735
   End
   Begin VB.Label lblStar3
      BackColor       =   &H80000005&
      Caption         =   "Co-Star:"
      Height          =   255
      Left            =   3360
      TabIndex        =   13
      Top             =   2040
      Width           =   735
   End
   Begin VB.Label lblStar2
      BackColor       =   &H80000005&
      Caption         =   "Co-Star:"
      Height          =   255
      Left            =   3360
      TabIndex        =   12
      Top             =   1560
      Width           =   735
   End
   Begin VB.Label lblStar1
      BackColor       =   &H80000005&
      Caption         =   "Star:"
      Height          =   255
      Left            =   3360
      TabIndex        =   11
      Top             =   1080
      Width           =   495
   End
   Begin VB.Label lblTitle
      BackColor       =   &H80000005&
      Caption         =   "Title:"
      Height          =   255
      Left            =   5400
      TabIndex        =   10
      Top             =   0
      Width           =   1215
   End
   Begin VB.Label lblMovieCount
      BackColor       =   &H80000005&
      Caption         =   "Movies in collection:  "
      Height          =   255
      Left            =   120
      TabIndex        =   1
      Top             =   240
      Width           =   3015
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Type Movie
  ID As String
  title As String
  star1 As String
  star2 As String
  star3 As String
  star4 As String
  genre1 As String
  genre2 As String
  genre3 As String
  year As String
  format As String
End Type
 
Private Type Star
  ID As String
  FirstName As String
  LastName As String
End Type
 
Private Type Genre
  ID As String
  Genre As String
End Type
 
Private Movies() As Movie
Private Stars() As Star
Private Genres() As Genre
Private NextMovieID As Integer
Private NextStarID As Integer
Private NextGenreID As Integer
 
Public Sub Form_Load()
Dim created As String
Dim ff As Long
Dim ctrl As Control
Me.BackColor = 16776960
For Each ctrl In Me.Controls
  If TypeOf ctrl Is Frame Or TypeOf ctrl Is _
   OptionButton Or TypeOf ctrl Is Label Then
    ctrl.BackColor = Me.BackColor
  End If
Next
 
If Len(Dir(App.Path & "\movies.txt")) = 0 Then
  ff = FreeFile()
  Open App.Path & "\movies.txt" For Append As #ff
  Close #ff
  created = created & "movies "
End If
If Len(Dir(App.Path & "\stars.txt")) = 0 Then
  ff = FreeFile()
  Open App.Path & "\stars.txt" For Append As #ff
  Close #ff
  created = created & "stars "
End If
If Len(Dir(App.Path & "\genres.txt")) = 0 Then
  ff = FreeFile()
  Open App.Path & "\genres.txt" For Append As #ff
  Close #ff
  created = created & "genres "
End If
If Len(Dir(App.Path & "\NextIDs.txt")) = 0 Then
  ff = FreeFile()
  Open App.Path & "\NextIDs.txt" For Append As #ff
    Print #ff, "1|0|0"
  Close #ff
  created = created & "nextIDs "
End If
 
If created <> "" Then
  If vbCancel = MsgBox("data files not found" & vbNewLine & vbNewLine & _
    "files created = " & created & vbNewLine & vbNewLine & "if unsure, " & _
    " click Cancel and check files location", vbOKCancel) Then
    Unload Me
    Exit Sub
  End If
End If
 
cboYear.AddItem "2000 >     "
cboYear.AddItem "1990 - 1999"
cboYear.AddItem "1980 - 1989"
cboYear.AddItem "1970 - 1979"
cboYear.AddItem "1960 - 1969"
cboYear.AddItem "1950 - 1959"
cboYear.AddItem "1940 - 1949"
cboYear.AddItem "1930 - 1939"
cboYear.AddItem "1920 - 1929"
cboYear.AddItem "        < 1920"
cboYear.AddItem "Unknown"
cboFormat.AddItem "DVD"
cboFormat.AddItem "VHS"
optListStar.Value = True
loadNextIDs
loadMovies
loadStars
loadGenres
End Sub
 
Private Sub loadMovies()
ReDim Movies(5000)
Dim ff As Long
Dim line As String
Dim bits() As String
 
ff = FreeFile()
Open App.Path & "\movies.txt" For Input As #ff
  Do While Not EOF(ff)
    Line Input #ff, line
    bits = Split(line, "|")
    Movies(bits(0)).ID = bits(0)
    Movies(bits(0)).title = bits(1)
    Movies(bits(0)).star1 = bits(2)
    Movies(bits(0)).star2 = bits(3)
    Movies(bits(0)).star3 = bits(4)
    Movies(bits(0)).star4 = bits(5)
    Movies(bits(0)).genre1 = bits(6)
    Movies(bits(0)).genre2 = bits(7)
    Movies(bits(0)).genre3 = bits(8)
    Movies(bits(0)).year = bits(9)
    Movies(bits(0)).format = bits(10)
  Loop
Close #ff
loadMoviesListBox
End Sub
 
Private Sub loadStars()
ReDim Stars(5000)
Dim ff As Long
Dim line As String
Dim bits() As String
 
ff = FreeFile()
Open App.Path & "\stars.txt" For Input As #ff
  Do While Not EOF(ff)
    Line Input #ff, line
    bits = Split(line, "|")
    Stars(bits(0)).ID = bits(0)
    Stars(bits(0)).FirstName = bits(1)
    Stars(bits(0)).LastName = bits(2)
  Loop
Close #ff
loadStarComboBoxes
End Sub
 
Private Sub loadGenres()
ReDim Genres(1000)
Dim ff As Long
Dim line As String
Dim bits() As String
 
ff = FreeFile()
Open App.Path & "\genres.txt" For Input As #ff
  Do While Not EOF(ff)
    Line Input #ff, line
    bits = Split(line, "|")
    Genres(bits(0)).ID = bits(0)
    Genres(bits(0)).Genre = bits(1)
  Loop
Close #ff
loadGenreComboBoxes
End Sub
 
Private Sub loadNextIDs()
Dim ff As Long
Dim line As String
Dim bits() As String
 
ff = FreeFile()
Open App.Path & "\NextIDs.txt" For Input As #ff
  Do While Not EOF(ff)
    Line Input #ff, line
    bits = Split(line, "|")
    NextMovieID = CInt(bits(0))
    NextStarID = CInt(bits(1))
    NextGenreID = CInt(bits(2))
  Loop
Close #ff
End Sub
Private Sub loadStarComboBoxes()
Dim FullName As String
Dim i As Integer
 
cboHidden.Clear
For i = 0 To NextStarID - 1
  If Stars(i).ID <> "" Then
    FullName = Stars(i).LastName & "|" & Stars(i).FirstName
    If Left(FullName, 1) = "|" Then FullName = Mid$(FullName, 2) '1-word names
    cboHidden.AddItem FullName
    cboHidden.ItemData(cboHidden.NewIndex) = Stars(i).ID
  End If
Next
 
cboStar1.Clear
cboStar2.Clear
cboStar3.Clear
cboStar4.Clear
For i = 0 To cboHidden.ListCount - 1
  cboHidden.ListIndex = i
If InStr(cboHidden.List(i), "|") > 0 Then
  FullName = Split(cboHidden.List(i), "|")(1) & " " & Split(cboHidden.List(i), "|")(0)
Else
  FullName = cboHidden.List(i)
End If
  cboStar1.AddItem FullName
  cboStar1.ItemData(cboStar1.NewIndex) = cboHidden.ItemData(cboHidden.ListIndex)
  cboStar2.AddItem FullName
  cboStar2.ItemData(cboStar2.NewIndex) = cboHidden.ItemData(cboHidden.ListIndex)
  cboStar3.AddItem FullName
  cboStar3.ItemData(cboStar3.NewIndex) = cboHidden.ItemData(cboHidden.ListIndex)
  cboStar4.AddItem FullName
  cboStar4.ItemData(cboStar4.NewIndex) = cboHidden.ItemData(cboHidden.ListIndex)
Next
End Sub
 
Private Sub loadGenreComboBoxes()
Dim i As Integer
 
cboGenre1.Clear
cboGenre2.Clear
cboGenre3.Clear
For i = 0 To NextGenreID - 1
  If Genres(i).ID <> "" Then
    cboGenre1.AddItem Genres(i).Genre
    cboGenre1.ItemData(cboGenre1.NewIndex) = Genres(i).ID
    cboGenre2.AddItem Genres(i).Genre
    cboGenre2.ItemData(cboGenre2.NewIndex) = Genres(i).ID
    cboGenre3.AddItem Genres(i).Genre
    cboGenre3.ItemData(cboGenre3.NewIndex) = Genres(i).ID
  End If
Next
End Sub
 
Private Sub loadMoviesListBox()
Dim i As Integer
 
lstMovies.Clear
For i = 0 To NextMovieID - 1
  If Movies(i).ID <> "" Then
    lstMovies.AddItem Movies(i).title
    lstMovies.ItemData(lstMovies.NewIndex) = Movies(i).ID
  End If
Next
lblMovieCount = "Movies in collection:  " & lstMovies.ListCount
End Sub
 
Private Sub lstMovies_Click()
If lstMovies.ListIndex <> -1 Then
  txtTitle.Text = lstMovies.Text
  cboStar1.Text = Stars(Movies(lstMovies.ItemData(lstMovies.ListIndex)).star1).FirstName & _
                  " " & Stars(Movies(lstMovies.ItemData(lstMovies.ListIndex)).star1).LastName
  cboStar2.Text = Stars(Movies(lstMovies.ItemData(lstMovies.ListIndex)).star2).FirstName & _
                  " " & Stars(Movies(lstMovies.ItemData(lstMovies.ListIndex)).star2).LastName
  cboStar3.Text = Stars(Movies(lstMovies.ItemData(lstMovies.ListIndex)).star3).FirstName & _
                  " " & Stars(Movies(lstMovies.ItemData(lstMovies.ListIndex)).star3).LastName
  cboStar4.Text = Stars(Movies(lstMovies.ItemData(lstMovies.ListIndex)).star4).FirstName & _
                  " " & Stars(Movies(lstMovies.ItemData(lstMovies.ListIndex)).star4).LastName
  cboGenre1.Text = Genres(Movies(lstMovies.ItemData(lstMovies.ListIndex)).genre1).Genre
  cboGenre2.Text = Genres(Movies(lstMovies.ItemData(lstMovies.ListIndex)).genre2).Genre
  cboGenre3.Text = Genres(Movies(lstMovies.ItemData(lstMovies.ListIndex)).genre3).Genre
  cboYear.Text = Movies(lstMovies.ItemData(lstMovies.ListIndex)).year
  cboFormat.Text = Movies(lstMovies.ItemData(lstMovies.ListIndex)).format
  lblTitle.Caption = "Title: " & Movies(lstMovies.ItemData(lstMovies.ListIndex)).ID
End If
End Sub
 
Private Sub saveNextIDs()
Dim ff As Long
ff = FreeFile()
Open App.Path & "\NextIDs.txt" For Output As #ff
  Print #ff, NextMovieID & "|" & NextStarID & "|" & NextGenreID
Close #ff
End Sub
 
Private Sub lstShowCollection_DblClick()
  lstShowCollection.Clear
End Sub
 
 
 
Private Sub txtAutoSelect_DblClick()
  txtAutoSelect.Text = ""
End Sub
 
Private Sub btnAddGenre_Click()
If InStr(txtAddGenre.Text, "|") Then
  MsgBox "Illegal chacter ""|"" detected"
  Exit Sub
End If
If txtAddGenre.Text = "" Then
    MsgBox "Please enter new genre description"
    Exit Sub
End If
If vbCancel = MsgBox("Adding new genre" & vbCrLf & vbCrLf & txtAddGenre.Text, _
                                 vbOKCancel, "Confirm Genre to add") Then
    Exit Sub
End If
 
Dim i As Integer
Dim ff As Long
 
For i = 0 To NextGenreID - 1
  If UCase(Genres(i).Genre) = UCase(txtAddGenre.Text) Then
    MsgBox "record already exists"
    Exit Sub
  End If
Next
 
Genres(NextGenreID).ID = NextGenreID
Genres(NextGenreID).Genre = txtAddGenre.Text
 
ff = FreeFile()
Open App.Path & "\genres.txt" For Append As #ff
  Print #ff, Genres(NextGenreID).ID & "|" & Genres(NextGenreID).Genre
Close #ff
 
cboGenre1.AddItem Genres(NextGenreID).Genre
cboGenre1.ItemData(cboGenre1.NewIndex) = Genres(NextGenreID).ID
cboGenre2.AddItem Genres(NextGenreID).Genre
cboGenre2.ItemData(cboGenre2.NewIndex) = Genres(NextGenreID).ID
cboGenre3.AddItem Genres(NextGenreID).Genre
cboGenre3.ItemData(cboGenre3.NewIndex) = Genres(NextGenreID).ID
NextGenreID = NextGenreID + 1
saveNextIDs
End Sub
 
Private Sub btnAddStar_Click()
If InStr(txtFirstName.Text, "|") Or InStr(txtLastName.Text, "|") Then
  MsgBox "Illegal chacter ""|"" detected"
  Exit Sub
End If
If InStr(txtFirstName.Text, " ") And txtLastName.Text = "" Then
    MsgBox "Illegal `space` character in one word name"
    Exit Sub
End If
If txtFirstName.Text = "" And txtLastName <> "" Then
    MsgBox "Either first name missing, or one-word" & vbCrLf & _
                        vbCrLf & "star name in incorrect box"
    Exit Sub
End If
If txtFirstName.Text = "" Then
    MsgBox "Please enter Star details"
    Exit Sub
End If
 
txtLastName.Text = Replace$(txtLastName.Text, " ", "_")
 
If vbCancel = MsgBox("Adding new star" & vbCrLf & vbCrLf & txtFirstName.Text & _
                       " " & txtLastName, vbOKCancel, "Confirm Add Star") Then
    Exit Sub
End If
 
Dim ff As Long
Dim i As Integer
 
If txtLastName.Text <> "" Then
  For i = 0 To NextStarID - 1
    If UCase(txtFirstName.Text) = UCase(Stars(i).FirstName) And _
       UCase(txtLastName.Text) = UCase(Stars(i).LastName) Then
       MsgBox "record already exists"
       Exit Sub
    End If
  Next
Else
  For i = 0 To NextStarID - 1
    If UCase(txtFirstName.Text) = UCase(Stars(i).LastName) Then
       MsgBox "record already exists"
       Exit Sub
    End If
  Next
End If
 
Stars(NextStarID).ID = NextStarID
Stars(NextStarID).FirstName = txtFirstName.Text
Stars(NextStarID).LastName = txtLastName.Text
 
ff = FreeFile()
Open App.Path & "\stars.txt" For Append As #ff
If Stars(NextStarID).LastName <> "" Then
  Print #ff, Stars(NextStarID).ID & "|" & Stars(NextStarID).FirstName & _
                                    "|" & Stars(NextStarID).LastName
Else
  Print #ff, Stars(NextStarID).ID & "|" & "|" & Stars(NextStarID).FirstName
End If
Close #ff
 
If Stars(NextStarID).LastName <> "" Then
  cboHidden.AddItem Stars(NextStarID).LastName & "|" & Stars(NextStarID).FirstName
Else
  cboHidden.AddItem Stars(NextStarID).FirstName
End If
cboHidden.ItemData(cboHidden.NewIndex) = Stars(NextStarID).ID
cboStar1.AddItem Stars(NextStarID).FirstName & " " & Stars(NextStarID).LastName, cboHidden.NewIndex
cboStar1.ItemData(cboStar1.NewIndex) = Stars(NextStarID).ID
cboStar2.AddItem Stars(NextStarID).FirstName & " " & Stars(NextStarID).LastName, cboHidden.NewIndex
cboStar2.ItemData(cboStar2.NewIndex) = Stars(NextStarID).ID
cboStar3.AddItem Stars(NextStarID).FirstName & " " & Stars(NextStarID).LastName, cboHidden.NewIndex
cboStar3.ItemData(cboStar3.NewIndex) = Stars(NextStarID).ID
cboStar4.AddItem Stars(NextStarID).FirstName & " " & Stars(NextStarID).LastName, cboHidden.NewIndex
cboStar4.ItemData(cboStar4.NewIndex) = Stars(NextStarID).ID
 
NextStarID = NextStarID + 1
saveNextIDs
End Sub
 
Private Sub btnAddMovie_Click()
If InStr(txtTitle.Text, "|") Then
  MsgBox "Illegal chacter ""|"" detected"
  Exit Sub
End If
If txtTitle.Text = "" Then
    MsgBox "Please enter movie title"
    Exit Sub
End If
If cboStar1.Text = "" Then
    MsgBox "Please select Star1"
    Exit Sub
End If
If cboStar2.Text = "" Then
    MsgBox "Please select Star2"
    Exit Sub
End If
If cboStar3.Text = "" Then
    MsgBox "Please select Star3"
    Exit Sub
End If
If cboStar4.Text = "" Then
    MsgBox "Please select Star4"
    Exit Sub
End If
If cboGenre1.Text = "" Then
    MsgBox "Please select Genre1"
    Exit Sub
End If
If cboGenre2.Text = "" Then
    MsgBox "Please select Genre2"
    Exit Sub
End If
If cboGenre3.Text = "" Then
    MsgBox "Please select Genre3"
    Exit Sub
End If
If cboYear.Text = "" Then
    MsgBox "Please select year made"
    Exit Sub
End If
If cboFormat.Text = "" Then
    MsgBox "Please select VHS or DVD"
    Exit Sub
End If
If vbCancel = MsgBox(txtTitle.Text & vbCrLf & vbCrLf & cboStar1.Text & _
    vbCrLf & cboStar2.Text & vbCrLf & cboStar3.Text & vbCrLf & cboStar4.Text & _
    vbCrLf & vbCrLf & cboGenre1.Text & vbCrLf & cboGenre2.Text & vbCrLf & _
    cboGenre3.Text & vbCrLf & vbCrLf & cboYear.Text & vbCrLf & cboFormat.Text, _
    vbOKCancel, "Confirm Movie to add") Then
    Exit Sub
End If
 
Dim title As String
Dim star1 As String
Dim star2 As String
Dim star3 As String
Dim star4 As String
Dim genre1 As String
Dim genre2 As String
Dim genre3 As String
Dim year As String
Dim format As String
Dim ff As Long
Dim i As Integer
 
title = txtTitle.Text
star1 = cboStar1.ItemData(cboStar1.ListIndex)
star2 = cboStar2.ItemData(cboStar2.ListIndex)
star3 = cboStar3.ItemData(cboStar3.ListIndex)
star4 = cboStar4.ItemData(cboStar4.ListIndex)
genre1 = cboGenre1.ItemData(cboGenre1.ListIndex)
genre2 = cboGenre2.ItemData(cboGenre2.ListIndex)
genre3 = cboGenre3.ItemData(cboGenre3.ListIndex)
year = cboYear.Text
format = cboFormat.Text
 
For i = 0 To NextMovieID - 1
 If UCase(Movies(i).title) = UCase(title) And _
    Movies(i).star1 = star1 And Movies(i).format = format Then
    MsgBox "record already exists"
    Exit Sub
 End If
Next
 
Movies(NextMovieID).ID = NextMovieID
Movies(NextMovieID).title = title
Movies(NextMovieID).star1 = star1
Movies(NextMovieID).star2 = star2
Movies(NextMovieID).star3 = star3
Movies(NextMovieID).star4 = star4
Movies(NextMovieID).genre1 = genre1
Movies(NextMovieID).genre2 = genre2
Movies(NextMovieID).genre3 = genre3
Movies(NextMovieID).year = year
Movies(NextMovieID).format = format
 
ff = FreeFile()
Open App.Path & "\movies.txt" For Append As #ff
  Print #ff, Movies(NextMovieID).ID & "|" & Movies(NextMovieID).title & "|" & _
         Movies(NextMovieID).star1 & "|" & Movies(NextMovieID).star2 & "|" & _
         Movies(NextMovieID).star3 & "|" & Movies(NextMovieID).star4 & "|" & _
         Movies(NextMovieID).genre1 & "|" & Movies(NextMovieID).genre2 & "|" & _
         Movies(NextMovieID).genre3 & "|" & Movies(NextMovieID).year & "|" & _
         Movies(NextMovieID).format
Close #ff
 
lstMovies.AddItem Movies(NextMovieID).title
lstMovies.ItemData(lstMovies.NewIndex) = Movies(NextMovieID).ID
lblMovieCount = "Movies in collection:  " & lstMovies.ListCount
lstMovies.Text = title
NextMovieID = NextMovieID + 1
saveNextIDs
End Sub
 
Private Sub btnShowList_Click()
Dim ID As String
Dim i As Integer
lstShowCollection.Clear
 
If optListStar.Value = True Then
  If cboStar1.Text = "" Then
    MsgBox "Please select a Star"
    Exit Sub
  End If
 
  ID = cboStar1.ItemData(cboStar1.ListIndex)
  For i = 0 To NextMovieID - 1
    If Movies(i).ID <> "" Then
      If Movies(i).star1 = ID Or Movies(i).star2 = ID _
      Or Movies(i).star3 = ID Or Movies(i).star4 = ID Then
        lstShowCollection.AddItem Movies(i).title
      End If
    End If
  Next
ElseIf optListGenre.Value = True Then
  If cboGenre1.Text = "" Then
    MsgBox "Please select Genre" & vbCrLf & "from topmost Genre List"
    Exit Sub
  End If
 
  ID = cboGenre1.ItemData(cboGenre1.ListIndex)
  For i = 0 To NextMovieID - 1
    If Movies(i).ID <> "" Then
      If Movies(i).genre1 = ID Or Movies(i).genre2 = ID _
      Or Movies(i).genre3 = ID Then lstShowCollection.AddItem Movies(i).title
    End If
  Next
ElseIf optListDVD.Value = True Then
    For i = 0 To NextMovieID - 1
      If Movies(i).ID <> "" Then
        If Movies(i).format = "DVD" Then lstShowCollection.AddItem Movies(i).title
      End If
    Next
ElseIf optListDecade.Value = True Then
    For i = 0 To NextMovieID - 1
      If Movies(i).ID <> "" Then
        If Movies(i).year = cboYear.Text Then
          lstShowCollection.AddItem Movies(i).title
      End If
      End If
    Next
End If
 
i = 0
Do Until i >= lstShowCollection.ListCount - 1
  If lstShowCollection.List(i) = lstShowCollection.List(i + 1) Then
    lstShowCollection.RemoveItem (i + 1)
  Else: i = i + 1
  End If
Loop
 
lblCollectionCount.Caption = "Collection = " & lstShowCollection.ListCount
 
If lstShowCollection.ListCount = 0 Then lstShowCollection.AddItem "No records found"
 
End Sub
 
Private Sub txtAutoSelect_Change()
 
Dim i As Integer
For i = 0 To lstMovies.ListCount - 1
    If LCase(Left(lstMovies.List(i), Len(txtAutoSelect.Text))) = _
                                   LCase(txtAutoSelect.Text) Then
        lstMovies.Text = lstMovies.List(i)
        Exit For
    End If
Next
 
End Sub
 
Private Sub btnClear_Click()
lstMovies.Text = ""
lblCollectionCount.Caption = ""
lstShowCollection.Clear
txtTitle.Text = ""
cboYear.ListIndex = -1
cboFormat.ListIndex = -1
txtStar1_DblClick
txtStar2_DblClick
txtStar3_DblClick
txtStar4_DblClick
txtGenre1_DblClick
txtGenre2_DblClick
txtGenre3_DblClick
txtFirstName.Text = ""
txtLastName.Text = ""
txtAddGenre.Text = ""
txtTitle.SetFocus
End Sub
 
Private Sub txtFirstName_DblClick()
txtLastName.Text = ""
txtFirstName.Text = ""
txtFirstName.SetFocus
End Sub
 
Private Sub txtAddGenre_DblClick()
txtAddGenre.Text = ""
End Sub
 
Private Sub txtLastName_DblClick()
txtLastName.Text = ""
txtFirstName.Text = ""
txtFirstName.SetFocus
End Sub
Private Sub txtStar1_Change()
Dim i As Integer
For i = 0 To cboStar1.ListCount - 1
    If LCase(Mid(cboStar1.List(i), InStrRev(cboStar1.List(i), " ") + 1, _
                         Len(txtStar1.Text))) = LCase(txtStar1.Text) Then
        cboStar1.Text = cboStar1.List(i)
        Exit For
    End If
Next
End Sub
 
Private Sub txtStar1_DblClick()
txtStar1.Text = ""
cboStar1.ListIndex = -1
End Sub
 
Private Sub txtStar2_Change()
Dim i As Integer
For i = 0 To cboStar2.ListCount - 1
    If LCase(Mid(cboStar2.List(i), InStrRev(cboStar2.List(i), " ") + 1, _
                         Len(txtStar2.Text))) = LCase(txtStar2.Text) Then
        cboStar2.Text = cboStar2.List(i)
        Exit For
    End If
Next
End Sub
 
Private Sub txtStar2_DblClick()
txtStar2.Text = ""
cboStar2.ListIndex = -1
End Sub
Private Sub txtStar3_Change()
Dim i As Integer
For i = 0 To cboStar3.ListCount - 1
    If LCase(Mid(cboStar3.List(i), InStrRev(cboStar3.List(i), " ") + 1, _
                         Len(txtStar3.Text))) = LCase(txtStar3.Text) Then
        cboStar3.Text = cboStar3.List(i)
        Exit For
    End If
Next
End Sub
 
Private Sub txtStar3_DblClick()
txtStar3.Text = ""
cboStar3.ListIndex = -1
End Sub
Private Sub txtStar4_Change()
Dim i As Integer
For i = 0 To cboStar4.ListCount - 1
    If LCase(Mid(cboStar4.List(i), InStrRev(cboStar4.List(i), " ") + 1, _
                         Len(txtStar4.Text))) = LCase(txtStar4.Text) Then
        cboStar4.Text = cboStar4.List(i)
        Exit For
    End If
Next
End Sub
 
Private Sub txtStar4_DblClick()
txtStar4.Text = ""
cboStar4.ListIndex = -1
End Sub
Private Sub txtGenre1_Change()
Dim i As Integer
For i = 0 To cboGenre1.ListCount - 1
    If LCase(Mid(cboGenre1.List(i), 1, Len(txtGenre1.Text))) = _
                                      LCase(txtGenre1.Text) Then
        cboGenre1.Text = cboGenre1.List(i)
        Exit For
    End If
Next
End Sub
 
Private Sub txtGenre1_DblClick()
txtGenre1.Text = ""
cboGenre1.ListIndex = -1
End Sub
Private Sub txtGenre2_Change()
Dim i As Integer
For i = 0 To cboGenre2.ListCount - 1
    If LCase(Mid(cboGenre2.List(i), 1, Len(txtGenre2.Text))) = _
                                      LCase(txtGenre2.Text) Then
        cboGenre2.Text = cboGenre2.List(i)
        Exit For
    End If
Next
End Sub
 
Private Sub txtGenre2_DblClick()
txtGenre2.Text = ""
cboGenre2.ListIndex = -1
End Sub
Private Sub txtGenre3_Change()
Dim i As Integer
For i = 0 To cboGenre3.ListCount - 1
    If LCase(Mid(cboGenre3.List(i), 1, Len(txtGenre3.Text))) = _
                                       LCase(txtGenre3.Text) Then
        cboGenre3.Text = cboGenre3.List(i)
        Exit For
    End If
Next
End Sub
 
Private Sub txtGenre3_DblClick()
txtGenre3.Text = ""
cboGenre3.ListIndex = -1
End Sub
 
Private Sub txtTitle_Change()
lblTitle.Caption = ""
End Sub
 
Private Sub txtTitle_DblClick()
txtTitle.Text = ""
End Sub
 
Private Sub btnEditGenre_Click()
If cboGenre1.Text = "" Then
    MsgBox "Please select genre to edit"
    Exit Sub
End If
If txtAddGenre.Text = "" Then
    MsgBox "Please enter new details"
    txtAddGenre.SetFocus
    Exit Sub
End If
If InStr(txtAddGenre.Text, "|") Then
  MsgBox "Illegal chacter ""|"" detected"
  Exit Sub
End If
 
If vbCancel = MsgBox("Replace " & vbTab & vbTab & cboGenre1.Text & _
         vbCrLf & vbCrLf & "with" & vbTab & vbTab & txtAddGenre.Text, _
                              vbOKCancel, "Confirm Edit Genre") Then
    Exit Sub
End If
 
Genres(cboGenre1.ItemData(cboGenre1.ListIndex)).Genre = txtAddGenre.Text
loadGenreComboBoxes
 
Dim i As Integer
Dim ff As Long
ff = FreeFile()
Open App.Path & "\genres.txt" For Output As #ff
  For i = 0 To NextGenreID - 1
    If Genres(i).ID <> "" Then Print #ff, Genres(i).ID & "|" & Genres(i).Genre
  Next
Close #ff
lstMovies_Click
End Sub
 
Private Sub btnEditStar_Click()
If cboStar1.Text = "" Then
    MsgBox "No Star selected"
    cboStar1.SetFocus
    Exit Sub
End If
If InStr(txtFirstName.Text, " ") And txtLastName.Text = "" Then
    MsgBox "Illegal `space` character in one word name"
    Exit Sub
End If
If txtFirstName.Text = "" And txtLastName <> "" Then
    MsgBox "Either first name missing, or one-word" & vbCrLf & vbCrLf & _
                                      "star name in incorrect box"
    Exit Sub
End If
If txtFirstName.Text = "" Then
    MsgBox "Please enter details of correct Star name"
    txtFirstName.SetFocus
    Exit Sub
End If
If InStr(txtFirstName.Text, "|") Or InStr(txtLastName.Text, "|") Then
  MsgBox "Illegal chacter ""|"" detected"
  Exit Sub
End If
 
txtLastName.Text = Replace$(txtLastName.Text, " ", "_")
 
If cboStar1.Text = txtFirstName.Text & " " & txtLastName.Text Then
    MsgBox "Details identical, nothing to change"
    Exit Sub
End If
If vbCancel = MsgBox("Replace " & vbTab & vbTab & cboStar1.Text & _
     vbCrLf & vbCrLf & "with" & vbTab & vbTab & txtFirstName.Text & _
       " " & txtLastName.Text, vbOKCancel, "Confirm Edit Star") Then
    Exit Sub
End If
Dim i As Integer
If txtLastName.Text <> "" Then
  For i = 0 To NextStarID - 1
    If UCase(txtFirstName.Text) = UCase(Stars(i).FirstName) And _
       UCase(txtLastName.Text) = UCase(Stars(i).LastName) Then
       If vbCancel = MsgBox("record already exists" & vbNewLine & vbNewLine & _
                  "click OK if changing capitalisation", vbOKCancel) Then Exit Sub
    End If
  Next
Else
  For i = 0 To NextStarID - 1
    If UCase(txtFirstName.Text) = UCase(Stars(i).LastName) Then
       If vbCancel = MsgBox("record already exists" & vbNewLine & vbNewLine & _
                  "click OK if changing capitalisation", vbOKCancel) Then Exit Sub
    End If
  Next
End If
Stars(cboStar1.ItemData(cboStar1.ListIndex)).FirstName = txtFirstName.Text
Stars(cboStar1.ItemData(cboStar1.ListIndex)).LastName = txtLastName.Text
Dim ff As Long
ff = FreeFile()
Open App.Path & "\stars.txt" For Output As #ff
  For i = 0 To NextStarID - 1
    If Stars(i).ID <> "" Then
      If Stars(i).LastName <> "" Then
        Print #ff, Stars(i).ID & "|" & Stars(i).FirstName & "|" & Stars(i).LastName
      Else
        Print #ff, Stars(i).ID & "|" & "|" & Stars(i).FirstName
      End If
    End If
  Next
Close #ff
loadStarComboBoxes
lstMovies_Click
End Sub
 
Private Sub btnEditMovie_Click()
Dim currentSelection As String: currentSelection = lstMovies.Text
Dim NewTitle As String
Dim NewStar1 As String
Dim NewStar2 As String
Dim NewStar3 As String
Dim NewStar4 As String
Dim NewGenre1 As String
Dim NewGenre2 As String
Dim NewGenre3 As String
Dim NewYear As String
Dim NewFormat As String
Dim NewStar1ID As String
Dim NewStar2ID As String
Dim NewStar3ID As String
Dim NewStar4ID As String
Dim NewGenre1ID As String
Dim NewGenre2ID As String
Dim NewGenre3ID As String
 
If InStr(txtTitle.Text, "|") Then
  MsgBox "Illegal chacter ""|"" detected"
  Exit Sub
End If
If txtTitle.Text = "" Then
    MsgBox "Please enter movie title"
    Exit Sub
Else: NewTitle = txtTitle.Text
End If
If cboStar1.Text = "" Then
    MsgBox "Please select Star1"
    Exit Sub
Else
  NewStar1 = cboStar1.Text
  NewStar1ID = cboStar1.ItemData(cboStar1.ListIndex)
End If
If cboStar2.Text = "" Then
    MsgBox "Please select Star2"
    Exit Sub
Else
  NewStar2 = cboStar2.Text
  NewStar2ID = cboStar2.ItemData(cboStar2.ListIndex)
End If
If cboStar3.Text = "" Then
    MsgBox "Please select Star3"
    Exit Sub
Else
  NewStar3 = cboStar3.Text
  NewStar3ID = cboStar3.ItemData(cboStar3.ListIndex)
End If
If cboStar4.Text = "" Then
    MsgBox "Please select Star4"
    Exit Sub
Else
  NewStar4 = cboStar4.Text
  NewStar4ID = cboStar4.ItemData(cboStar4.ListIndex)
End If
If cboGenre1.Text = "" Then
    MsgBox "Please select Genre1"
    Exit Sub
Else
  NewGenre1 = cboGenre1.Text
  NewGenre1ID = cboGenre1.ItemData(cboGenre1.ListIndex)
End If
If cboGenre2.Text = "" Then
    MsgBox "Please select Genre2"
    Exit Sub
Else
  NewGenre2 = cboGenre2.Text
  NewGenre2ID = cboGenre2.ItemData(cboGenre2.ListIndex)
End If
If cboGenre3.Text = "" Then
    MsgBox "Please select Genre3"
    Exit Sub
Else
  NewGenre3 = cboGenre3.Text
  NewGenre3ID = cboGenre3.ItemData(cboGenre3.ListIndex)
End If
If cboYear.Text = "" Then
    MsgBox "Please select year made"
    Exit Sub
Else: NewYear = cboYear.Text
End If
If cboFormat.Text = "" Then
    MsgBox "Please select VHS or DVD"
    Exit Sub
Else: NewFormat = cboFormat.Text
End If
 
lstMovies_Click
 
If txtTitle.Text <> NewTitle Then
    If vbCancel = MsgBox("Replace" & vbTab & txtTitle.Text & _
    vbCrLf & vbCrLf & "With" & vbTab & NewTitle, vbOKCancel, _
    "Confirm change to movie details") Then Exit Sub
   
    Movies(lstMovies.ItemData(lstMovies.ListIndex)).title = NewTitle
    currentSelection = NewTitle
End If
 
If cboStar1.Text <> NewStar1 Then
    If vbCancel = MsgBox("Replace" & vbTab & cboStar1.Text & _
    vbCrLf & vbCrLf & "With" & vbTab & NewStar1, vbOKCancel, _
    "Confirm change to movie title") Then Exit Sub
   
    Movies(lstMovies.ItemData(lstMovies.ListIndex)).star1 = NewStar1ID
End If
 
If cboStar2.Text <> NewStar2 Then
    If vbCancel = MsgBox("Replace" & vbTab & cboStar2.Text & _
    vbCrLf & vbCrLf & "With" & vbTab & NewStar2, vbOKCancel, _
    "Confirm change to movie title") Then Exit Sub
   
    Movies(lstMovies.ItemData(lstMovies.ListIndex)).star2 = NewStar2ID
End If
 
If cboStar3.Text <> NewStar3 Then
    If vbCancel = MsgBox("Replace" & vbTab & cboStar3.Text & _
    vbCrLf & vbCrLf & "With" & vbTab & NewStar3, vbOKCancel, _
    "Confirm change to movie title") Then Exit Sub
   
    Movies(lstMovies.ItemData(lstMovies.ListIndex)).star3 = NewStar3ID
End If
 
If cboStar4.Text <> NewStar4 Then
    If vbCancel = MsgBox("Replace" & vbTab & cboStar4.Text & _
    vbCrLf & vbCrLf & "With" & vbTab & NewStar4, vbOKCancel, _
    "Confirm change to movie title") Then Exit Sub
   
    Movies(lstMovies.ItemData(lstMovies.ListIndex)).star4 = NewStar4ID
End If
 
If cboGenre1.Text <> NewGenre1 Then
    If vbCancel = MsgBox("Replace" & vbTab & cboGenre1.Text & _
    vbCrLf & vbCrLf & "With" & vbTab & NewGenre1, vbOKCancel, _
    "Confirm change to movie title") Then Exit Sub
   
    Movies(lstMovies.ItemData(lstMovies.ListIndex)).genre1 = NewGenre1ID
End If
 
If cboGenre2.Text <> NewGenre2 Then
    If vbCancel = MsgBox("Replace" & vbTab & cboGenre2.Text & _
    vbCrLf & vbCrLf & "With" & vbTab & NewGenre2, vbOKCancel, _
    "Confirm change to movie title") Then Exit Sub
   
    Movies(lstMovies.ItemData(lstMovies.ListIndex)).genre2 = NewGenre2ID
End If
 
If cboGenre3.Text <> NewGenre3 Then
    If vbCancel = MsgBox("Replace" & vbTab & cboGenre3.Text & _
    vbCrLf & vbCrLf & "With" & vbTab & NewGenre3, vbOKCancel, _
    "Confirm change to movie title") Then Exit Sub
   
    Movies(lstMovies.ItemData(lstMovies.ListIndex)).genre3 = NewGenre3ID
End If
 
If cboYear.Text <> NewYear Then
    If vbCancel = MsgBox("Replace" & vbTab & cboYear.Text & _
    vbCrLf & vbCrLf & "With" & vbTab & NewYear, vbOKCancel, _
    "Confirm change to movie title") Then Exit Sub
   
    Movies(lstMovies.ItemData(lstMovies.ListIndex)).year = NewYear
End If
 
If cboFormat.Text <> NewFormat Then
    If vbCancel = MsgBox("Replace" & vbTab & cboFormat.Text & _
    vbCrLf & vbCrLf & "With" & vbTab & NewFormat, vbOKCancel, _
    "Confirm change to movie title") Then Exit Sub
   
    Movies(lstMovies.ItemData(lstMovies.ListIndex)).format = NewFormat
End If
 
Dim i As Integer
Dim ff As Long
ff = FreeFile()
Open App.Path & "\movies.txt" For Output As #ff
  For i = 0 To NextMovieID - 1
    If Movies(i).ID <> "" Then
    Print #ff, Movies(i).ID & "|" & Movies(i).title & "|" & _
         Movies(i).star1 & "|" & Movies(i).star2 & "|" & _
         Movies(i).star3 & "|" & Movies(i).star4 & "|" & _
         Movies(i).genre1 & "|" & Movies(i).genre2 & "|" & _
         Movies(i).genre3 & "|" & Movies(i).year & "|" & _
         Movies(i).format
    End If
  Next
Close #ff
loadMoviesListBox
lstMovies.Text = currentSelection
End Sub
 

back    top    main page    vb snippets page      java snippets page     vbscript snippets page   email    Page last modified