Jessie
Nov 16th, 1999, 12:54 PM
day two of trying to figure this out can any one please help
icannot figiure out how to get the txtTotal to work with the way i have this combo box loaded and adding the cbolistindex to the grid i keep getting subscipt out of range here's my code i have tried it i don't know how many ways error, error and more errors
Private Sub Create_Movie_List() 'loads moviedata to cbomovies
Dim strTemp As String 'declare variables
Dim intCount As Integer
Dim intFreeFile As Integer
Dim intInstr As Integer
intCount = 0 'declare values
intFreeFile = FreeFile
Open MovieData For Input As #intFreeFile
Do 'start of loop
ReDim Preserve S_TagMovieFile(intCount)
Input #intFreeFile, strTemp
intInstr = InStr(strTemp, "|")
'finds movie name in string
S_TagMovieFile(intCount).strMovieName = Left(strTemp, intInstr - 1)
'finds movie price in string
S_TagMovieFile(intCount).dblPrice = Right(strTemp, Len(strTemp) - (intInstr))
'adds movie names to combobox
cboMovies.AddItem S_TagMovieFile(intCount).strMovieName
cboMovies.ItemData(cboMovies.NewIndex) = intCount
intCount = intCount + 1
'end of loop
Loop Until EOF(intFreeFile)
Close #intFreeFile
End Sub
Private Sub cmdAddMovie_Click()
If cboMovies.ListIndex < 0 Then Exit Sub
'adds moviename and cost to grid
grdMovieSelect.AddItem Chr(9) & cboMovies & Chr(9) & Format(S_TagMovieFile(cboMovies.ItemData(cboMovies.ListIndex)).dblPrice, "currency")
grdMovieSelect.Row = intMovieCount + 1
intMovieCount = intMovieCount + 1
grdMovieSelect.Rows = intMovieCount + 1
Movie_Price
End Sub
Public Sub Movie_Price()
Dim iIndex As Integer
Dim dblTempDollar As Double
ReDim S_TagMovieFile(0)
dblTempDollar = 0
With FrmVideo
For iIndex = 0 To intMovieCount - 1
ReDim Preserve S_TagMovieFile(iIndex)
.grdMovieSelect.Row = iIndex + 1
.grdMovieSelect.Col = 1
S_TagMovieFile(iIndex).strMovieName = .grdMovieSelect.Text
.grdMovieSelect.Col = 2
S_TagMovieFile(iIndex).dblPrice = .grdMovieSelect.Text
dblTempDollar = dblTempDollar + S_TagMovieFile(iIndex).dblPrice
Next iIndex
.txtTotal = Format(dblTempDollar, "currency")
End With
End Sub
Private Sub cmdDelete_Click()
If grdMovieSelect.Rows = 1 Then
Exit Sub
End If
grdMovieSelect.RemoveItem grdMovieSelect.RowSel
icannot figiure out how to get the txtTotal to work with the way i have this combo box loaded and adding the cbolistindex to the grid i keep getting subscipt out of range here's my code i have tried it i don't know how many ways error, error and more errors
Private Sub Create_Movie_List() 'loads moviedata to cbomovies
Dim strTemp As String 'declare variables
Dim intCount As Integer
Dim intFreeFile As Integer
Dim intInstr As Integer
intCount = 0 'declare values
intFreeFile = FreeFile
Open MovieData For Input As #intFreeFile
Do 'start of loop
ReDim Preserve S_TagMovieFile(intCount)
Input #intFreeFile, strTemp
intInstr = InStr(strTemp, "|")
'finds movie name in string
S_TagMovieFile(intCount).strMovieName = Left(strTemp, intInstr - 1)
'finds movie price in string
S_TagMovieFile(intCount).dblPrice = Right(strTemp, Len(strTemp) - (intInstr))
'adds movie names to combobox
cboMovies.AddItem S_TagMovieFile(intCount).strMovieName
cboMovies.ItemData(cboMovies.NewIndex) = intCount
intCount = intCount + 1
'end of loop
Loop Until EOF(intFreeFile)
Close #intFreeFile
End Sub
Private Sub cmdAddMovie_Click()
If cboMovies.ListIndex < 0 Then Exit Sub
'adds moviename and cost to grid
grdMovieSelect.AddItem Chr(9) & cboMovies & Chr(9) & Format(S_TagMovieFile(cboMovies.ItemData(cboMovies.ListIndex)).dblPrice, "currency")
grdMovieSelect.Row = intMovieCount + 1
intMovieCount = intMovieCount + 1
grdMovieSelect.Rows = intMovieCount + 1
Movie_Price
End Sub
Public Sub Movie_Price()
Dim iIndex As Integer
Dim dblTempDollar As Double
ReDim S_TagMovieFile(0)
dblTempDollar = 0
With FrmVideo
For iIndex = 0 To intMovieCount - 1
ReDim Preserve S_TagMovieFile(iIndex)
.grdMovieSelect.Row = iIndex + 1
.grdMovieSelect.Col = 1
S_TagMovieFile(iIndex).strMovieName = .grdMovieSelect.Text
.grdMovieSelect.Col = 2
S_TagMovieFile(iIndex).dblPrice = .grdMovieSelect.Text
dblTempDollar = dblTempDollar + S_TagMovieFile(iIndex).dblPrice
Next iIndex
.txtTotal = Format(dblTempDollar, "currency")
End With
End Sub
Private Sub cmdDelete_Click()
If grdMovieSelect.Rows = 1 Then
Exit Sub
End If
grdMovieSelect.RemoveItem grdMovieSelect.RowSel