CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 1998
    Posts
    23

    VB Q&A 2 simple ones





    (1) how do i declare variables at the top of my code? Where/How?


    (2) similar to the above where do i put code that needs to be executed imediately at run time.


    Thanks


    Christopher (I`m still checking the manual)

  2. #2
    Join Date
    Nov 1998
    Posts
    9

    Re: VB Q&A 2 simple ones



    1) If you want to delcare variables that have scope in the Form ... declare them where it says General ... It is a good idea to type in Option Explicit before doing this, this means that your variables have to be declared.

    If you want them to have scope of an event such as button click, declare the variable at the top of the subroutine. You can also declare global variables by creating a bas module.


    2) If your project is starting from a form ... the initialization code would go in the Form Load Subroutine. You can also start a project from a sub Main. You create this Subroutine in a bas module you create. Then write whatever code you need to execute as the program is initialized ... to load your form use Form.Load and Form.Show


    Gordito

  3. #3
    Join Date
    Nov 1998
    Posts
    23

    Re: VB Q&A 2 simple ones(thanks)



    I did finaly find the information that allowed me to declare variables.

    it seems i also have to use the word Private when declaring them of i get an error about being defined outside a procedure.


    As far as intialising my code i`ll try your suggestions.


    Thanks.


    Christopher

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured