Why isn't this code filling array?

Which line of code causes the problem if you step through in a debugger?
Also you may find it easier to use the .Net file handling methods in System.IO rather than the VB6 FileOpen, Input, FileClose methods.
 
Thanks for your reply
Actually the Debugger is landing on the "Next" (and I assuming it will on the "Previous" button if it could get that far) button that calls the array
Code:
Private Sub MovePrevious(ByVal sender As System.Object, ByVal e As System.EventArgs) _
                Handles mnuActionPrevious.Click, btnPrevious.Click
        If Not intCurrent = UBound(CdArray) Then

            intCurrent -= 1

        End If

        UpdateFormData()
    End Sub

It says UBound(CDArray) (that line anyway) = nothing or array cant be null or something


Thanks
ROb
 
I dont know - is trhis what you mean?
Like this? This is in my module:

Code:
  Structure CdType
        Dim strArtist As String
        Dim strTitle As String
        Dim strYear As String
        Dim strCategory As String

    End Structure
    Public CdArray() As CdType

#Region "Utility Procedures (non-UI)"

    Public Sub OpenFile()
         Get an available file number, store it in the global variable, and open the file.
        gintCdFileNum = FreeFile()
        FileOpen(gintCdFileNum, gstrCdFileName, OpenMode.Input)
    End Sub


    Public Sub GetNextRecord()

        Get the next record, but only if we arent already at the end of the file
        If Not EOF(gintCdFileNum) Then
            Input(gintCdFileNum, gstrArtist)
            Input(gintCdFileNum, gstrTitle)
            Input(gintCdFileNum, gshtYear)
            Input(gintCdFileNum, gstrCategory)


        End If

Yes I do have option strict on

Rob
 
Do I put it right underneath it in the Module?
It is appearing outside the "body" and wont let me put it right underneath
R
 
Man,
I am sorry to take up so much of your time... nothing is happening still I am not going to the next record with the "next "button - but no errors thats a plus
R
 
What code is in the Next button? Also what code is at the end of the GetNextRecord routine.
Also this might be a lot easier avoiding the VB6 file routines.
 
thanks
Code:
Private Sub MoveNext(ByVal sender As System.Object, ByVal e As System.EventArgs) _
            Handles mnuActionNext.Click, btnNext.Click
        

        If Not intCurrent = UBound(CdArray) Then

            intCurrent += 1

        End If

        UpdateFormData()
    End Sub

    Private Sub MovePrevious(ByVal sender As System.Object, ByVal e As System.EventArgs) _
                Handles mnuActionPrevious.Click, btnPrevious.Click
        If Not intCurrent = UBound(CdArray) Then

            intCurrent -= 1

        End If

        UpdateFormData()
    End Sub

GetNextRecord:

Code:
  Public Sub GetNextRecord()

        Get the next record, but only if we arent already at the end of the file
        If Not EOF(gintCdFileNum) Then
            Input(gintCdFileNum, gstrArtist)
            Input(gintCdFileNum, gstrTitle)
            Input(gintCdFileNum, gshtYear)
            Input(gintCdFileNum, gstrCategory)


        End If



    End Sub

LoadCDArray is after the next and previous - is the oder the problem?

R
 
Back
Top