locked
Class cannot be indexed because it has no default property? RRS feed

  • Question

  • I am new to classes, and I am new to Visual Basic in general, but I am working on a multi class program. The code seems to be correct, but I am trying on instantiate a class oject with the code:

    BookEntry = BookEntry(txtISBN.Text, txtTitle.Text, txtAuthor.Text, Category)
    
    

    Which has a contructor of:

     

        Sub New(ByVal ISBN As String, ByVal Title As String, ByVal Author As String, ByVal Category As String)
    
            MyBase.New()
    
            _ISBN = ISBN
    
            _Title = Title
    
            _Author = Author
    
            _Category = Category
    
        End Sub

    I have no errors in my code (unless they are logical)  except I keep getting a Class <Classname> cannot be indexed because it has no default property error.

    I have Option Strict on, and I have re-written both my construtor and instantiator code.

    If anyone has any idea what this might be your help would be very greatly appreciated.


    UOK Games Webmaster, Network Administrator http://uokgames.com
    • Edited by Brandyn Abel Friday, April 2, 2010 12:38 PM Fixded Typo
    Friday, April 2, 2010 12:37 PM

Answers

  • I have solved this, I just forgot the new keyword in my dim statement

    • Marked as answer by Jeff Shan Tuesday, April 6, 2010 6:58 AM
    Friday, April 2, 2010 12:54 PM

All replies

  • Variables must start with letters!
    Friday, April 2, 2010 12:46 PM
  • I have solved this, I just forgot the new keyword in my dim statement

    • Marked as answer by Jeff Shan Tuesday, April 6, 2010 6:58 AM
    Friday, April 2, 2010 12:54 PM
  • Variables must start with letters!
    You probably know this by now, but it's common practice to use underscores to start local private variables.
    Tom Stock
    Tuesday, June 21, 2011 7:25 PM