Help On Vb2005 Code!

A Member? Please Login  
type your username and password to login
Date: December 05, 2008, 05:31 AM
268336 members and 165350 Topics
Latest Member: roorbereibusa
Nairaland [Nigerian Forum] Home Help Search Who is currently online? Login Register
Nairaland Forum  |  Technology  |  Programming (Moderator: Dual Core)  |  Help On Vb2005 Code!
Pages: (1) Go Down Send this topic Notify of replies
Author Topic: Help On Vb2005 Code!  (Read 161 views)
gfather (m)
Help On Vb2005 Code!
« on: September 10, 2007, 08:56 AM »

Could anybody help me out here? I just started working with Visual Basic 2005 and i have a problem in achieving a certain result through codes.
In a project with multiple forms(including dialog forms) ,which can be called upon from one main form; I declared a variable in the code view of the main form and initialized it to zero because i would refer to it from the other forms and also perform some cummulative additions to it. The problem i have now is that after declaring the variable at the top of the code module on the main form;

       Public intScore As Integer = 0

When i want to use this variable to perform some aritmethic operations on other forms within the same project i keep getting a warning statement;
 
    "variable is used before it has been assigned a value; a null reference exception could result at runtime "

so i guess my problem is either how to link the forms with one another since i 'think' my declaration snippet above is appropriate or something else is missing  or wrong.
Please i would appreciate it if anyone can help me out. i'm online most attimes so you could holla.
onochie_online@yahoo.co.uk
Or txt me i could reach back- 07035224890
             
luckyCO
Re: Help On Vb2005 Code!
« #1 on: September 10, 2007, 02:06 PM »

gfather global declaration are done that way. By that you have succeded making intScore availble from anywhere in the project once that form is mentioned. Say dim frm as new form1.
frm.intScore, now you can do anything with this frm.intScore not intScore.

But if you want to access intScore from any place within the project then you can do the following steps;

Insert a module say  Module1 then inside its procedure enter Public intScore As Integer = 0

With this you have made intScore availbale in all the projects without having to create an instance of it just like in the form.
Hope this helps you if not call 08036025235 or post in Post your VB6.0 Problems here , thread created by me.

 Php  I Have E-book For Mcsd Training Kit And Exam  Developer/database Administrator Wanted For Major Projects  Page 2
Pages: (1) Go Up Send Topic to Friend by E-mail Reply 
Google
 
Web www.nairaland.com
Sections: TV/Movies (2) Music/Radio (2) Celebrities Job Talk Jobs/Vacancies (2) Career Talk Romance Books Politics Sports Fashion Travel
Health Schooling Religion General(2) Business Webmaster Programming Computers Phones Cars & Trucks

Links: Page1 Page2 Page3 Page4 Page5 Page6 Page7 Page8 Page9 Page10

Nairaland is owned by Oluwaseun Osewa
Nairaland Forum | Powered by SMF 1.0.12.
© 2001-2005, Lewis Media. All Rights Reserved.