Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,209,231 members, 8,005,346 topics. Date: Sunday, 17 November 2024 at 09:22 PM |
Nairaland Forum / Science/Technology / Programming / Help On Vb2005 Code! (1230 Views)
(1) (Reply)
Help On Vb2005 Code! by gfather(m): 8:56am On Sep 10, 2007 |
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 |
Re: Help On Vb2005 Code! by luckyCO(m): 2:06pm On Sep 10, 2007 |
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. |
(1) (Reply)
8 Tips To Make Life Smoother For Programmers / How Do I Create A Java App That Works With A Relational Database? / Free Email And Phone Number Extractor
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 10 |