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. General Programming
  3. Visual Basic
  4. Are arrays of objects possible ?

Are arrays of objects possible ?

Scheduled Pinned Locked Moved Visual Basic
data-structureshelpquestion
8 Posts 4 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.
  • G Offline
    G Offline
    Geoff_3001
    wrote on last edited by
    #1

    I have an object Public Class Plateobj Public Order As String Public Row As String Public Column As String End Class I want to create an array of the Plateobj's Dim plateinfo() As Plateobj And then refrence them as follow plateinfo(0).Order = "One" But I get the following error "Object refrence not set to an instance of an object" I guess I am doing something daft, any clues welcome Ta Very Much

    K J 2 Replies Last reply
    0
    • G Geoff_3001

      I have an object Public Class Plateobj Public Order As String Public Row As String Public Column As String End Class I want to create an array of the Plateobj's Dim plateinfo() As Plateobj And then refrence them as follow plateinfo(0).Order = "One" But I get the following error "Object refrence not set to an instance of an object" I guess I am doing something daft, any clues welcome Ta Very Much

      K Offline
      K Offline
      Kevin Nicol
      wrote on last edited by
      #2

      you still have to initialize the object as follows Public Class Plateobj Public Order As String Public Row As String Public Column As String End Class Dim plateinfo() As Plateobj '***** plateinfo(0) = new plateobj() '***** plateinfo(0).Order = "One"

      G 1 Reply Last reply
      0
      • K Kevin Nicol

        you still have to initialize the object as follows Public Class Plateobj Public Order As String Public Row As String Public Column As String End Class Dim plateinfo() As Plateobj '***** plateinfo(0) = new plateobj() '***** plateinfo(0).Order = "One"

        G Offline
        G Offline
        Geoff_3001
        wrote on last edited by
        #3

        Kevin, Thanks tried that and still get the same error (on the initalise). Geoff

        K 1 Reply Last reply
        0
        • G Geoff_3001

          Kevin, Thanks tried that and still get the same error (on the initalise). Geoff

          K Offline
          K Offline
          Kevin Nicol
          wrote on last edited by
          #4

          try this 'declare the array dim plateInfo() as Plateobj 'set its bounds redim plateInfo(10) 'initialze the array item plateinfo(0) = new Plateobj() 'now work with it plateInfo(0).order = "One"

          S G 2 Replies Last reply
          0
          • K Kevin Nicol

            try this 'declare the array dim plateInfo() as Plateobj 'set its bounds redim plateInfo(10) 'initialze the array item plateinfo(0) = new Plateobj() 'now work with it plateInfo(0).order = "One"

            S Offline
            S Offline
            SpartanSoft
            wrote on last edited by
            #5

            Are the objects in the area always going to be Plateobj? If so you should consider using Generics. Kinds Pseudo Code... in C#, List LobjList = new List(); LobjList.Add(new Plateobj()); LobjList[0].order = "One;

            Christopher Pond Innovative Technology Solutions SpartanSoft.net.

            G 1 Reply Last reply
            0
            • K Kevin Nicol

              try this 'declare the array dim plateInfo() as Plateobj 'set its bounds redim plateInfo(10) 'initialze the array item plateinfo(0) = new Plateobj() 'now work with it plateInfo(0).order = "One"

              G Offline
              G Offline
              Geoff_3001
              wrote on last edited by
              #6

              AaaaHa It works thanks, maybe the day was not wasted Cheers Geoff

              1 Reply Last reply
              0
              • S SpartanSoft

                Are the objects in the area always going to be Plateobj? If so you should consider using Generics. Kinds Pseudo Code... in C#, List LobjList = new List(); LobjList.Add(new Plateobj()); LobjList[0].order = "One;

                Christopher Pond Innovative Technology Solutions SpartanSoft.net.

                G Offline
                G Offline
                Geoff_3001
                wrote on last edited by
                #7

                Um I suspect I will end up with other object as I am reading data from oracle and flat data file and writing updates back. I will give it a go though, knowledege is power as they say. Thanks Geoff

                1 Reply Last reply
                0
                • G Geoff_3001

                  I have an object Public Class Plateobj Public Order As String Public Row As String Public Column As String End Class I want to create an array of the Plateobj's Dim plateinfo() As Plateobj And then refrence them as follow plateinfo(0).Order = "One" But I get the following error "Object refrence not set to an instance of an object" I guess I am doing something daft, any clues welcome Ta Very Much

                  J Offline
                  J Offline
                  jchigg2000
                  wrote on last edited by
                  #8

                  Use a Collection!

                  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