| | |
single execution of code at start...help required
Thread Solved |
•
•
Join Date: Nov 2009
Posts: 46
Reputation:
Solved Threads: 0
i have 4-5 forms...all of them are called by each other by some or other procedure...now i want to initialize an variable with an integer value only when my program starts....
my problem is where ever i declare the variable...the form gets called and the variable gets re-initialized...
or
can i declare my integer variable globally and initialize it with a value???
dim globalvariable as integer = 5
gives an error....
i might sound naive...but just hav got stuck on this..
Plz help....
my problem is where ever i declare the variable...the form gets called and the variable gets re-initialized...
or
can i declare my integer variable globally and initialize it with a value???
dim globalvariable as integer = 5
gives an error....
i might sound naive...but just hav got stuck on this..
Plz help....
Last edited by pankaj.garg; Nov 23rd, 2009 at 3:09 pm.
•
•
Join Date: Mar 2009
Posts: 1,211
Reputation:
Solved Threads: 220
0
#2 Nov 23rd, 2009
In module...
However, you will not be able to change this value if you are wanting to have this value change.
Now, there is another way if you have your program start up in a sub main...
Good Luck
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Public Const MyVar As Integer = 5
Now, there is another way if you have your program start up in a sub main...
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Option Explicit Public MyValue As Integer Sub Main() MyValue = 5 Form1.Show End Sub
Good Luck
If anyone has helped you solve your problem, please mark your thread as solved.
Thanks
Thanks
•
•
Join Date: Nov 2009
Posts: 46
Reputation:
Solved Threads: 0
0
#3 Nov 24th, 2009
Thanks alot...
i cant use the first method..as i need to change the value of variable..
for second method - i havnt used sub main as of now...but seems it will solve my problem...do i need to declare anything else for can i just call my starting form in main()...just like that???
i cant use the first method..as i need to change the value of variable..
for second method - i havnt used sub main as of now...but seems it will solve my problem...do i need to declare anything else for can i just call my starting form in main()...just like that???
•
•
•
•
In module...
However, you will not be able to change this value if you are wanting to have this value change.Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Public Const MyVar As Integer = 5
Now, there is another way if you have your program start up in a sub main...
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Option Explicit Public MyValue As Integer Sub Main() MyValue = 5 Form1.Show End Sub
Good Luck
•
•
Join Date: Mar 2009
Posts: 1,211
Reputation:
Solved Threads: 220
1
#4 Nov 24th, 2009
Add a module, and add...
Then add the code you need to inside of sub main but don't forget to put in your Form1.Show or your program will look like it does not even run. Next, GoTo Project>Properties and on the right there is a combo box right under the words "Startup Object:". Select Sub Main and hit OK.
Good Luck
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Sub Main() End Sub
Good Luck
If anyone has helped you solve your problem, please mark your thread as solved.
Thanks
Thanks
![]() |
Similar Threads
- Installing software on Linux: source code (*nix Software)
- Array of hashes in c++ (C++)
- excel add-in with data from access (VB.NET)
- JSP database connectivity according to Model View Controller (MVC) Model 2 (JSP)
- time for execution of code (C)
- Very important change to the code snippet highlighter (IT Professionals' Lounge)
- Why app is looking for "Default.aspx" (ASP.NET)
- Where do you get the code to start a forum? (Social Media and Online Communities)
- Using x86 Assembly Language with Microsoft Visual C++ (C++)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: VB backup and restore program
- Next Thread: MMcontrol does not play previously played .wav file
Views: 611 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
* 6 access activex add ado application banned basic beep bmp box c++ calculator click client code coffeehouse college column convert copy creative database designer desktop dissertations dissertationthesis edit error excel file filter flex form hardware header ide image implements inboxinvb installation installer interaction keypress listview looping machine macro mail match memory messagebox microsoft number open pause pdf picture pos prime print program programmer prompt query random range range-objects readfile registration remotesqlserverdatabase report reports retrieve save score search sites spectateswamp sql string struct subroutine table textbox time timer variable variables vb vb6 vb6.0 vba vista visual visualbasic web window windows






