Why can't I move a variable declaration from inside a Sub to the Declarations area?

I'm writing an app and so far, so good. But I need wider access to an array defined in my "Form_Load" sub.
Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' Assign checkboxes to an array.
Dim Checkboxes() As CheckBox = {chkThumb01, chkThumb02, chkThumb03, chkThumb04, _
chkThumb05, chkThumb06, chkThumb07, chkThumb08, chkThumb09, chkThumb10}
Moving the declaration ("Dim Checkboxes()...") from "Sub frmMain_Load" up into the Declarations space just above it breaks my program. :(
I tried putting it in a Module and that fails too. The ONLY place it work's is in Form_Load (it's not related to being an array because at least one standard integer variable declaration has this problem too.)
I have other variables in the Declarations area that work fine (eg: "Dim bolChanges as Boolean"), but for some reason, I can't move others out into what
should be a more global namespace.
Anyone know what's going on? Thx.

No, because this makes no difference.
Background #1: If you do not write your own constructor (=Sub New), the VB compiler adds a default constructor. It contains a call to Sub InitializeComponent. In this Sub, the controls are created and assigned to chkThumb01 etc. You see it if you type "Sub
New[Enter]":
Sub New()
InitializeComponent()
End Sub
Background #2: If you write
Public Class Test
Private values As Integer() = {1, 2, 3}
End Class
it is identical to
Public Class Test
Private values As Integer()
Sub New()
values = New Integer() {1, 2, 3}
End Sub
End Class
As you can see, the assignments that you do to fields of the class in the declaration line are actually executed in the constructor (sub new).
Now put both backgrounds together. Consequently, this code
Public Class Form1
Private buttons As Button() = {Button1, Button2, Button3}
End Class
is identical to this one:
Public Class Form1
Private buttons As Button()
Sub New()
buttons = New Button() {Button1, Button2, Button3}
InitializeComponent()
End Sub
End Class
Obviously, the assignment to variable "buttons" is done before the call to Sub InitializeComponent. At this point, variables Button1, Button2 and  Button3 are still empty (Nothing) because they will be set in Sub InitializeComponent. Consequently,
the array buttons contains just {Nothing, Nothing, Nothing}
In opposite, if the array buttons is set in the Load event, Button1, Button2 and Button3 have already been set before, Consequently, the array buttons correctly contains references to the three buttons.
Armin

Similar Messages

  • Whenever I modify a photo in Iphoto it puts it in a "modified" subfolder. Why can't I move this modified file (I changed name) back to the Iphoto main file so I can see it when I open my photos?

    Whenever I modify a photo in Iphoto it puts it in a "modified" subfolder. Why can't I move this modified file (I changed and saved file name) back to the Iphoto main file so I can see it when I open my photos?

    A good general step for strange issues is to renew the iPhoto preference file - quit iPhoto and go to "your user name" ==> library ==> preferences ==> com.apple.iPhoto.plist and trash it - launch iPhoto which creates a fresh new default preference file and reset any personal preferences you have changed and if you have moved the iPhoto library repoint to it. This may help
    This does not affect your photos or any database information (keywords, faces, places, ratings, etc) in any way - they are stored in the iPhoto library - the iPhoto preference file simply controls how iPhoto works - which is why renewing it is a good first step.
    If that does not cure it backup up your iPhoto library and rebuild it - depress the option and command keys and launch iphoto and use the options there - exact option depends on teh version you have
    And always remember - NEVER make any changes of any sort to the structure or content of the iPhoto library - nothing - no deletions - no name changes - nothing
    LN 

  • Why can't I copy my photo files from my Mac Pro to the External Hard Drive?

    Whay can't I copy my photo files from my Mac Book Pro to my External Hard Drive?

    Are you trying to copy the actual files or the iPhoto Library? Are you tryuing to do it in iPhoto or in a finder window?

  • Why can I not move files in LR from 1 HDD to another

    Hi there.
    LR 4
    I need to move a bunch of pictures located in different sub-folders on Drive C: to my new 2Tb Drive D:
    I try to move it in LR via the import function with MOVE. But, they are all greyed out (not selectable) and when I try to move 1-by-1 by right-clicking on a picture, a message is displayed telling me that the picture is already in the catalogue. I know it is already in the catalogue. All I need to do is to move it to another HDD.
    How would you do this? I have just thought of deleting all files in the catalogue and import them then, but it just does not feel right.
    Your suggestions will be very valueble.

    Do you see your new @TB drive D in LR? If yes, create a new folder there as John said. In Grid View on the left side is the folders panel. You create the new folder in the folders panel. Right-click where it says "D:" and select <Create folder inside D:>.
    Then still in the folders panel drag-and-drop the folders from your old drive C to the new folder you just created on drive D.
    But as John advised make a backup of your catalog first. Go >Edit>Catalog Settings and at the bottom of the General tab select <Every time Lr exits>. Then close Lr and the backup dialog will appear. Choose a location for your backup - maybe your new external drive and create the backup. Lr will close down after that. Re-open Lr and do the move of the folders as described above.
    PS: Do NOT use the import function. You said "is it on the right side?" No! that's in the Import dialog. Cancel import and go to Grid View. the folders panel is on the left side there.
    Message was edited by: web-weaver

  • Why can't I move or delete a simple destop clock after instaLLING Lion?

    why can't I move or delete a simple destop clock after instaLLING Lion?

    Are your refering to the printer driver software? You'll need to go to HP's site and see if they have updated drives for Lion for your printer model. There site might also have oter useful information regardsing using this printer with Lion.
    In fact a quick Google search turned up this HP site OS X 10.7 Lion: Installing and Using the Printer with Lion which might answer your questions
    good luck

  • Using QuickTime Pro with an .mpg movie, why can I only get it to play from the beginning, but not from any other point in the video?

    Using QuickTime Pro with an .mpg movie, why can I only get it to play from the beginning, but not from any other point in the video? How can I fix this?
    Baffled in SB

    What format of MPG is this?  Is this an MPEG1 or MPEG2 video?  How was the video created?

  • Why can't i move some music to my iPhone from iTunes?

    why can't i move some music to my iPhone from iTunes? i have some songs the tracks names are faded and wont move to my iphone and others that arnt faded and still wont move?

    For the faded tracks right mouse click on them and select Check Selection.
    What are the others that will not move?

  • Why can I not move items within a playlist?

    why can I not move items within a playlist?
    I should be able to drag songs up and down - and I can in other lists - but not on a new one I just created. ??

    Brandcast, I'd suggest you post in a new topic. Although your question is the same, apparently the answer isn't. Any topic that was originally started over 2 months ago may relate to a different version of iTunes (neither you nor the original poster say which version you use) and who knows what may happen between versions.
    Message was edited by: Limnos - user has started a new topic

  • Why can't I move photos from Lightroom to Elements II for further editing?

    Why can't I move photos from Lightroom to Elements II for further editing?

    You can. select the image you want to edit externally then :-
    In the top toolbar Go to :- Photo, Edit in Adobe Photoshop Elements Editor
    If this isn't working got to :-
    Edit, Preferences, External Editing
    .....and check that Ps Elements is set there. You are able to set two external editors.
    Good luck!

  • Why can't I move the icons around on my iMac hard drive?  They just pop back in place when I release the mouse.

    iMac Mavericks
    Why can't I move folders around on my iMac hard drive?  They just pop right back in place.  I've selected Sort By None. This just started happening this morning so I must have done something!   Any help?

    This is a shot in the dark, but try this:
    log-in to your iCloud account with your Apple ID
    change your password
    ensure your billing information is up-to-date
    attempt to re-enable your Keychain (again)

  • Why can't I move the "name" column??

    This is a question that has been bothering me for a very long time. Why can't I move the "Name" column in the library (or playlist) view away from it's left position? It seems to be locked into place. I can move and arrange artist, album, time, bitrate, track #, etc etc etc to any configuration I so desire, but yet the name column remains eternally glued to the left side of that pane, never to be moved.
    The reason I ask, is because when I organize my music, I don't immediately think of track names, I think of artists. Especially in this day of cds I am hard pressed to recall individual song names. At home my albums and cds are filed by artist name, not by song name (physically impossible, obviously). It's a natural tree-like organization... artist->album->song name. I want to configure the library view in iTunes to match this same logical hiearchy but for some reason iTunes will not let me do this one extremly simple thing... argh and double argh!! Is there any reason for this? Is there any way to solve this?

    Chad hello,
    Everybody here has given you good advice so I will explain why the name column can not be moved...
    Your Music library is a data base and a data base has to have at least one totally unique index field for each file... now it can not be the Artist as you can have as many songs as you like by the same artist... same reason for the album, one album can have many songs but the same album name... same for genre etc.
    The only thing that can be unique is the song title... If you put the exact same song by the same artist the program will assign a unique name by adding a number in front of the extension for each duplicate .... example
    Song Name.mp3
    Song Name_1.mp3
    Song Name_2.mp3
    So when you think about it the song name is the only thing that is different... one album by the same Artist may have more than one track of exactly the same length, size, genre, composer etc. moving through all fields except the name....
    Now why can't you move the name column... well all the other fields do not have to be unique so you can move and/or remove these columns but if you could remove the name column you could end up with more than one entry in your library looking exactly the same.... you have to have something that allows you to separate them and that is the unique index field 'Song Name'....it could not work any other way..
    hope you can follow all that.... take care... TP

  • Why can't I move a folder from contacts to the mail address line?

    Why can't I move a folder from Contacts to the address line in mail?

    If all of the contacts don't get moved into the address field(s), it's possible that some of the contacts in a Group contain  information but not email addresses for those individuals.
    Don't really know what else to suggest except, possibly, that you delete, then re-create the problem Groups.

  • Why can't I move attach pics from photo browser

    Why can't I move pics to email using my photo browser?

    If all of the contacts don't get moved into the address field(s), it's possible that some of the contacts in a Group contain  information but not email addresses for those individuals.
    Don't really know what else to suggest except, possibly, that you delete, then re-create the problem Groups.

  • Why can't i move pasted selection? the move tool has no effect.

    Why can't i move the pasted selection.  it was cut from another photo and copied to this one.  It was dropped in the middle of the photo but the move tool has no effect on it.
    thankx

    I discovered that I had to be on that layer, click on the recompose tool, then click on a corner to bring up the green check indicator, then click on the center and it would move. In the old program I just clicked onto the move tool and it would move.
    Thanks for responding.

  • Why can I not move songs/playlist from my iPhone5 to my iTunes on new laptop?

    why can't I move songs/playlist from my iPhone5 to my iTunes on new laptop?

    The sync is one way - computer to iphone.  The exception is itunes purchases:  File>Devices>Transfer Purchases
    Copy everything from your old computer, or your backup copy of your old computer, to your new one.

Maybe you are looking for

  • How to delete sub types in a wage type

    hi experts, how to delete the subtypes in a wage type . with out deleting the wage type but it should not display in the wage type list

  • Hey my macbook white unibody is coming up with a dark screen that is telling me to restart, how do i get rid of it?

    I actually have a couple questions.      I bought a used Macbook 2009 unibody that still has snow leopard. It recently has been coming up with a darkened screen telling me to restart. My first question is how do i get rid of that? Next i don't no the

  • Clean installing mountain lion while keeping snow leopard?

    Hello, I have a question... I newly buy an SSD and at the same time I am thinking to upgrading to Mountain Lion... My operating system is snow leopard now. I am thinking to download Mountain Lion and make a bootable flash disk. Then cleanly install i

  • Best way to change locations?

    I would like to know if there is a better way to move mappings and process flows between different test environments. I designed a mapping and process flow on one machine then used the export/import metadata mechanism to move the work to a different

  • Change log format of petstore

    Hi everybody The log entry format of petstore 1.4 is of the form: 150.0.0.1 - - [02/Feb/2006:00:32:38 +0530] "GET /petstore/item.screen?item_id=EST-16 HTTP/1.1" 200 9739 I want to change this log format so that it includes session id information too.