Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Array of custom classes problem [modified]

Array of custom classes problem [modified]

Scheduled Pinned Locked Moved ASP.NET
helpmysqldata-structures
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    LukeV
    wrote on last edited by
    #1

    Hi! I have an array of custom classes. When I try to set a variable with one of the array item, I get this error: Microsoft VBScript runtime error '800a01a8' Object required: '[undefined]' I guess I'm not far off but I must be missing something. Here's my code ( Important lines are in bold ):

    class CReviews
     private m_IDProd
     private m_aReviews
    	
     public sub GetReviews(IDProd)
      i = 1
      m_IDProd = IDProd
      mySQL = "SELECT * FROM ProductReviews WHERE IDProd = " & IDProd & ";"
      set rs = conn.execute(mySQL)
    		
      if not rs.eof then
       m_aReviews = Array( i )
       rs.movefirst
    		
       do while not rs.eof
        ReDim m_aReviews( i )
    				
        Set review = New CReview
        review.GetReview( rs("ID") )
        Set m_aReviews( i ) = review
    				
        i = i + 1
        rs.movenext
       loop
      end if
     end sub
    	
     public function GetReviewCount()
      GetReviewCount = UBound( m_aReviews )
     end function
    	
     public function GetReview(nIndex)
      if nIndex > 0 AND nIndex <= GetReviewCount() then
       GetReview = m_aReviews( nIndex )
      else
       GetReview = nothing
      end if
     end function
    end class
    
    
    class CReview
     private m_ID
     private m_ReviewEn
    	
     public sub GetReview(ID)
      'do stuff
     end sub
    	
     public property Get ReviewEn()
      ReviewEn = m_ReviewEn
     end property
    end class
    
    
    sub GetReview(IDProd)
     Set reviews = New CReviews
     reviews.GetReviews( IDProd )
     response.Write( reviews.GetReviewCount() )
    	
     'This line generates the error
     Set review = reviews.GetReview( 1 )
     if review <> nothing then
      response.Write( review.ReviewEn() )
     end if
    end sub
    

    Thanks! Luc -- modified at 13:21 Saturday 29th July, 2006

    I 2 Replies Last reply
    0
    • L LukeV

      Hi! I have an array of custom classes. When I try to set a variable with one of the array item, I get this error: Microsoft VBScript runtime error '800a01a8' Object required: '[undefined]' I guess I'm not far off but I must be missing something. Here's my code ( Important lines are in bold ):

      class CReviews
       private m_IDProd
       private m_aReviews
      	
       public sub GetReviews(IDProd)
        i = 1
        m_IDProd = IDProd
        mySQL = "SELECT * FROM ProductReviews WHERE IDProd = " & IDProd & ";"
        set rs = conn.execute(mySQL)
      		
        if not rs.eof then
         m_aReviews = Array( i )
         rs.movefirst
      		
         do while not rs.eof
          ReDim m_aReviews( i )
      				
          Set review = New CReview
          review.GetReview( rs("ID") )
          Set m_aReviews( i ) = review
      				
          i = i + 1
          rs.movenext
         loop
        end if
       end sub
      	
       public function GetReviewCount()
        GetReviewCount = UBound( m_aReviews )
       end function
      	
       public function GetReview(nIndex)
        if nIndex > 0 AND nIndex <= GetReviewCount() then
         GetReview = m_aReviews( nIndex )
        else
         GetReview = nothing
        end if
       end function
      end class
      
      
      class CReview
       private m_ID
       private m_ReviewEn
      	
       public sub GetReview(ID)
        'do stuff
       end sub
      	
       public property Get ReviewEn()
        ReviewEn = m_ReviewEn
       end property
      end class
      
      
      sub GetReview(IDProd)
       Set reviews = New CReviews
       reviews.GetReviews( IDProd )
       response.Write( reviews.GetReviewCount() )
      	
       'This line generates the error
       Set review = reviews.GetReview( 1 )
       if review <> nothing then
        response.Write( review.ReviewEn() )
       end if
      end sub
      

      Thanks! Luc -- modified at 13:21 Saturday 29th July, 2006

      I Offline
      I Offline
      Ista
      wrote on last edited by
      #2

      if( not review ) -- then error ----

      -------------------------------------------------------- 1 line of code equals many bugs. So don't write any!! My mad coder blog

      L 1 Reply Last reply
      0
      • I Ista

        if( not review ) -- then error ----

        -------------------------------------------------------- 1 line of code equals many bugs. So don't write any!! My mad coder blog

        L Offline
        L Offline
        LukeV
        wrote on last edited by
        #3

        ??? :confused:

        I 1 Reply Last reply
        0
        • L LukeV

          ??? :confused:

          I Offline
          I Offline
          Ista
          wrote on last edited by
          #4

          sorry i dont do VB if( review is nothing ) then -- do some error code --- end if

          -------------------------------------------------------- 1 line of code equals many bugs. So don't write any!! My mad coder blog

          L 1 Reply Last reply
          0
          • I Ista

            sorry i dont do VB if( review is nothing ) then -- do some error code --- end if

            -------------------------------------------------------- 1 line of code equals many bugs. So don't write any!! My mad coder blog

            L Offline
            L Offline
            LukeV
            wrote on last edited by
            #5

            No, the problem is that I can't retreive the object from the array. The returned object is always null. So I don't know if I'm storing the objects correctly in the array or if I retreive the object correctly... Thanks! :)

            1 Reply Last reply
            0
            • L LukeV

              Hi! I have an array of custom classes. When I try to set a variable with one of the array item, I get this error: Microsoft VBScript runtime error '800a01a8' Object required: '[undefined]' I guess I'm not far off but I must be missing something. Here's my code ( Important lines are in bold ):

              class CReviews
               private m_IDProd
               private m_aReviews
              	
               public sub GetReviews(IDProd)
                i = 1
                m_IDProd = IDProd
                mySQL = "SELECT * FROM ProductReviews WHERE IDProd = " & IDProd & ";"
                set rs = conn.execute(mySQL)
              		
                if not rs.eof then
                 m_aReviews = Array( i )
                 rs.movefirst
              		
                 do while not rs.eof
                  ReDim m_aReviews( i )
              				
                  Set review = New CReview
                  review.GetReview( rs("ID") )
                  Set m_aReviews( i ) = review
              				
                  i = i + 1
                  rs.movenext
                 loop
                end if
               end sub
              	
               public function GetReviewCount()
                GetReviewCount = UBound( m_aReviews )
               end function
              	
               public function GetReview(nIndex)
                if nIndex > 0 AND nIndex <= GetReviewCount() then
                 GetReview = m_aReviews( nIndex )
                else
                 GetReview = nothing
                end if
               end function
              end class
              
              
              class CReview
               private m_ID
               private m_ReviewEn
              	
               public sub GetReview(ID)
                'do stuff
               end sub
              	
               public property Get ReviewEn()
                ReviewEn = m_ReviewEn
               end property
              end class
              
              
              sub GetReview(IDProd)
               Set reviews = New CReviews
               reviews.GetReviews( IDProd )
               response.Write( reviews.GetReviewCount() )
              	
               'This line generates the error
               Set review = reviews.GetReview( 1 )
               if review <> nothing then
                response.Write( review.ReviewEn() )
               end if
              end sub
              

              Thanks! Luc -- modified at 13:21 Saturday 29th July, 2006

              I Offline
              I Offline
              Ista
              wrote on last edited by
              #6

              LukeV wrote:

              Set review = New CReview review.GetReview( rs("ID") ) Set m_aReviews( i ) = review

              Try this: Set m_aReviews( i ) = review.GetReview( rs("ID") )

              -------------------------------------------------------- 1 line of code equals many bugs. So don't write any!! My mad coder blog

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups