Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello All

The problem may lie elsewhere but I believe the array is not being filled - I get a �value cannot be null� error when I hit the "next" but on my form - the (obvious) next record to be displayed

 

Can someone see something?

 

Private Sub LoadCDArray()

       Dim intCDCount As Integer

       ' Open the file
       Do Until EOF(gintCdFileNum)
           If intCDCount / 10 = Int(intCDCount / 10) Then
               ReDim Preserve CdArray(intCDCount + 10)

           End If


           ' Load the data in a loop

           Input(gintCdFileNum, CdArray(intCDCount).strArtist)
           Input(gintCdFileNum, CdArray(intCDCount).strTitle)
           Input(gintCdFileNum, CdArray(intCDCount).strYear)
           Input(gintCdFileNum, CdArray(intCDCount).strCategory)

           intCDCount += 1
       Loop
       ReDim Preserve CdArray(intCDCount - 1)
       '' Close the file
       'FileClose(gintCdFileNum)
   End Sub


End Class

 

Thanks

Rob

Posted

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

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 can't be null or something

 

 

Thanks

ROb

Posted

I don't know - is trhis what you mean?

Like this? This is in my module:

 

 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 aren't 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

Posted

thanks

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:

 


 Public Sub GetNextRecord()

       'Get the next record, but only if we aren't 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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...