473,379 Members | 1,355 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

From The Old Times

I used to be a Fortran programmer, trying now VB. It atosnishes me that "initial values asigned to a program", at the very top of the VB code took the new values calculated else were is it that a "normal" feature for VB or thre's something wrong with the VB version I've got?
Thanks for the answers
Aug 26 '08 #1
2 1007
Stewart Ross
2,545 Expert Mod 2GB
Hi, and Welcome to Bytes!

If variables are declared at the top of a code module instead of within each procedure or subroutine they will be global in scope to that module. Further, if the code is in a public module (one which Access shows in the Modules tab, and not form or report code modules which are effectively private in scope) then such variables are global to the whole application. In such circumstances values can be carried forward from a previous use.

This can also happen if a variable is defined using the Static keyword to allow values to be retained between procedure calls, instead of being destroyed on completion. And one other circumstance springs to mind: parameters passed to subroutines and functions are passed by reference by default (as pointers to the actual value) so changes made to such values within the sub or function will also change the local copy of the variable in the calling routine - a sort of deliberate side effect - unless the keyword ByVal is used to ensure that the value alone is passed.

The norm in VB and VBA is to define variables within local functions and subroutines, not globally to the code module unless there is a need for such global variables. Further, even though VBA uses implied default values for variables (0 for numeric values, empty strings for strings, and so on), it is good practice not to rely on this but to explicitly zero or specify the state for the variables used.


I am not sure from what you wrote if any of these situations applies to you; it would have helped if you had posted a sample of your code for us to see.

-Stewart
Aug 26 '08 #2
missinglinq
3,532 Expert 2GB
Stew has given an excellent overview on the use of variables within Access VBA. Like Stewart, I'm not sure if it will be of any use to you because, to be frank, I have no idea what
It atosnishes me that "initial values asigned to a program", at the very top of the VB code took the new values calculated else were
means. Perhaps if you could review your original post and rephrase it more clearly we could be of more help to you.

Linq ;0)>
Aug 27 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Daniel Cloutier | last post by:
Hi, is it possible to edit or write Word-files out of a Python-Program? thx in advance daniel
8
by: Charles Nadeau | last post by:
I was trying to relocate my transaction log to a bigger drive using sp_movedevice but I made a mistake in the syntax of the second parameter and put only the path, not the path and the file name....
8
by: alanstew | last post by:
With the body tag calling out 'window onload', a function with a 'window.open' fails at the 'window.open' line. If I cut out the body tag, the function executes as normal. At first I thought it...
4
by: Garry Freemyer | last post by:
I'm trying to convert this macro to a c# function but I have a big problem. It's on the LEFT side of an assignment statement and I am extremely flustered over this one because I'm a little rusty...
87
by: John Rivers | last post by:
Hello everybody, I just wondered if anybody else has noticed this? It takes around 6 seconds to start debugging a very simple ASPX page with VS.NET whereas VB6 takes under 0.5 seconds, even...
6
by: MadMan2004 | last post by:
Hello all! I'm having a problem with a project I'm working on and I'd like to ask for anyone's input that might be helpful. I'm building a rather large front-end application connecting to an...
20
by: Development - multi.art.studio | last post by:
Hello everyone, i just upgraded my old postgres-database from version 7.1 to 7.4.2. i dumped out my 7.1 database (with pg_dump from 7.1) as an sql-file with copy-commands and to one file using...
4
by: viuxrluxvbbc | last post by:
Hi im trying to write a program that will read in numbers and display them in ascending order along with a count of how many times it repeats. i got the numerical order portion done but cant figure...
4
by: stj911 | last post by:
http://counterpunch.org/rahni04072007.html Test Tube Zealots: The American Chemical Society Terminates the Membership of Chemists from Iran By DAVID N. RAHNI The American Chemical Society...
5
by: Silgd1 | last post by:
Hey All.... I am creating web page using Netbeans 6.0. I use A jspf (java server page fragment) that is included in most of the other pages. There are several hyperlinks on the jspf that...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.