Click to See Complete Forum and Search --> : VB Q&A 2 simple ones


Christopher
November 15th, 1998, 01:39 AM
(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)

christopher
November 15th, 1998, 01:39 AM
(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)

Gordito
November 15th, 1998, 08:31 AM
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

Christopher
November 15th, 1998, 11:06 AM
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

christopher
November 15th, 1998, 11:06 AM
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