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. Access to arraylist globaly

Access to arraylist globaly

Scheduled Pinned Locked Moved Visual Basic
question
11 Posts 3 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.
  • W Offline
    W Offline
    WestSideRailways
    wrote on last edited by
    #1

    Hi there, How do i make an arraylist available globaly. I know that the easy way is to make it a (Dare I say it :)) Global variable.:omg:

    N C 2 Replies Last reply
    0
    • W WestSideRailways

      Hi there, How do i make an arraylist available globaly. I know that the easy way is to make it a (Dare I say it :)) Global variable.:omg:

      N Offline
      N Offline
      nlarson11
      wrote on last edited by
      #2

      you can make the variable shared within a class public class Common public shared oaArray as new arraylist end class ----- any code: common.oarraylist.add("??????")

      W 1 Reply Last reply
      0
      • N nlarson11

        you can make the variable shared within a class public class Common public shared oaArray as new arraylist end class ----- any code: common.oarraylist.add("??????")

        W Offline
        W Offline
        WestSideRailways
        wrote on last edited by
        #3

        Thanks for that.:):cool:

        1 Reply Last reply
        0
        • W WestSideRailways

          Hi there, How do i make an arraylist available globaly. I know that the easy way is to make it a (Dare I say it :)) Global variable.:omg:

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          A global variable is the only way to make it available 'globally'.  A better choice is to say 'who needs to see this, and in what context'.  For example, can you pass it to the intended clients via a delegate ?

          Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

          N W 2 Replies Last reply
          0
          • C Christian Graus

            A global variable is the only way to make it available 'globally'.  A better choice is to say 'who needs to see this, and in what context'.  For example, can you pass it to the intended clients via a delegate ?

            Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

            N Offline
            N Offline
            nlarson11
            wrote on last edited by
            #5

            Christain, using 'shared' will also make it available globally to the project and within referenced objects.

            C 1 Reply Last reply
            0
            • N nlarson11

              Christain, using 'shared' will also make it available globally to the project and within referenced objects.

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              Of course it will - the point is, he knows it's a bad idea, so why not talk about alternatives ?

              Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

              1 Reply Last reply
              0
              • C Christian Graus

                A global variable is the only way to make it available 'globally'.  A better choice is to say 'who needs to see this, and in what context'.  For example, can you pass it to the intended clients via a delegate ?

                Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

                W Offline
                W Offline
                WestSideRailways
                wrote on last edited by
                #7

                A global variable is the only way to make it available 'globally'. A better choice is to say 'who needs to see this, and in what context'. For example, can you pass it to the intended clients via a delegate posted by Christian Graus - C+++ MVP This is a good question:) I have had a look and 8 out of 27 procedures need to see my Global Var.BTW I have put 3 more in there.:):omg: 1 is a arraylist 1 is a string 2 are int. A little info. my application is a image viewing program, i ask the user to select the directory that they want to view...put the dir listing into a string and put the image names into the array. The rest of the program deals with displaying the images by clicking on verious menu's & buttons. Which is why i need global var. I split up the directory listing and display that if the user want too. if there is an easier way to do this, i am open to ideas....just remember i am a newbie to VB2005 programming:-O

                N 1 Reply Last reply
                0
                • W WestSideRailways

                  A global variable is the only way to make it available 'globally'. A better choice is to say 'who needs to see this, and in what context'. For example, can you pass it to the intended clients via a delegate posted by Christian Graus - C+++ MVP This is a good question:) I have had a look and 8 out of 27 procedures need to see my Global Var.BTW I have put 3 more in there.:):omg: 1 is a arraylist 1 is a string 2 are int. A little info. my application is a image viewing program, i ask the user to select the directory that they want to view...put the dir listing into a string and put the image names into the array. The rest of the program deals with displaying the images by clicking on verious menu's & buttons. Which is why i need global var. I split up the directory listing and display that if the user want too. if there is an easier way to do this, i am open to ideas....just remember i am a newbie to VB2005 programming:-O

                  N Offline
                  N Offline
                  nlarson11
                  wrote on last edited by
                  #8

                  Christian, I don't claim to know it all so please teach me, I'm curious: A delegate is a more or less a memory pointer to some routine. Given that, how would a delegate help? How does the delegate "expose" the arraylist variable? You would need to call a routine for adding or removing or searching, or returning the arraylist itself, etc. With all of that needed functionality could one single pointer give the developer that? You can't overload a delegate can you? Also, I would need to pass the pointer to every object that needed it which may or may not possible depending on how the object was created. Thanks, Nathan

                  C 1 Reply Last reply
                  0
                  • N nlarson11

                    Christian, I don't claim to know it all so please teach me, I'm curious: A delegate is a more or less a memory pointer to some routine. Given that, how would a delegate help? How does the delegate "expose" the arraylist variable? You would need to call a routine for adding or removing or searching, or returning the arraylist itself, etc. With all of that needed functionality could one single pointer give the developer that? You can't overload a delegate can you? Also, I would need to pass the pointer to every object that needed it which may or may not possible depending on how the object was created. Thanks, Nathan

                    C Offline
                    C Offline
                    Christian Graus
                    wrote on last edited by
                    #9

                    nlarson11 wrote:

                    Given that, how would a delegate help?

                    Because a global variable is essentialy the easy solution to the question 'how do I make this visible in more than one place', when often the real question is 'when my classes data is updated, I need to let some clients know about it'.  As such, you can define an event, such as 'ImageListUpdated', which passes the list directly to the clients that subscribe to it.  This means that the access to the information is one way, and rigidly defined in terms of when it occurs.

                    nlarson11 wrote:

                    You can't overload a delegate can you?

                    More than one client can subscribe to an event, so even if three classes need the message, it is not a big deal

                    nlarson11 wrote:

                    Also, I would need to pass the pointer to every object that needed it which may or may not possible depending on how the object was created.

                    When would that not be possible ? How is it different to having it exposed on a global, in that regard ?

                    Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

                    W 1 Reply Last reply
                    0
                    • C Christian Graus

                      nlarson11 wrote:

                      Given that, how would a delegate help?

                      Because a global variable is essentialy the easy solution to the question 'how do I make this visible in more than one place', when often the real question is 'when my classes data is updated, I need to let some clients know about it'.  As such, you can define an event, such as 'ImageListUpdated', which passes the list directly to the clients that subscribe to it.  This means that the access to the information is one way, and rigidly defined in terms of when it occurs.

                      nlarson11 wrote:

                      You can't overload a delegate can you?

                      More than one client can subscribe to an event, so even if three classes need the message, it is not a big deal

                      nlarson11 wrote:

                      Also, I would need to pass the pointer to every object that needed it which may or may not possible depending on how the object was created.

                      When would that not be possible ? How is it different to having it exposed on a global, in that regard ?

                      Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

                      W Offline
                      W Offline
                      WestSideRailways
                      wrote on last edited by
                      #10

                      Another excellent reponce Christian:) I don't need to define an event as the event is allready happening when the user selected the directory to view the images from. The images are on the users computer, all i'm doing is getting their path\file names. The problem comes when the user wants to flip though the images as this is a seperate event. At the moment this is not a problem,as I'm using Public Shared var. (See I did not use the word Global):):) a question.... how much time & memory would it take to load into a imagelist 300+ images, of course some of the images could be different sizes, which then rules out using Imagelist. Myself I have a directory which contains images of different sizes, and i'm sure other users would be the same. So I don't think that I'll be using Imagelist any time soon.;P

                      C 1 Reply Last reply
                      0
                      • W WestSideRailways

                        Another excellent reponce Christian:) I don't need to define an event as the event is allready happening when the user selected the directory to view the images from. The images are on the users computer, all i'm doing is getting their path\file names. The problem comes when the user wants to flip though the images as this is a seperate event. At the moment this is not a problem,as I'm using Public Shared var. (See I did not use the word Global):):) a question.... how much time & memory would it take to load into a imagelist 300+ images, of course some of the images could be different sizes, which then rules out using Imagelist. Myself I have a directory which contains images of different sizes, and i'm sure other users would be the same. So I don't think that I'll be using Imagelist any time soon.;P

                        C Offline
                        C Offline
                        Christian Graus
                        wrote on last edited by
                        #11

                        WestSideRailways wrote:

                        how much time & memory would it take to load into a imagelist 300+ images

                        I"m not sure, but the images themselves are passed by ref, so I wouldn't expect it to be much I'd just put them in a List if I had to pass them around.

                        Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

                        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