473,834 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Speeding up my code

All,
I have built a database recently which resides on a network server which
is constantly being re-structured. This is something I have no control over
so have had to incorporate a means by which the backend moving will not
cause too much of a headache and anyone can fix.
I decided to use an INI file to store several variables which can and often
do change.
I've also added a logging procedure which writes events to a text file to
aid me with ironing bugs out. Every time an event occurs, the READ_INI
procedure is being called to find out paths and file names to write to which
seems a little inefficient to me.

I have a splash screen within the database and was thinking that I could use
the 'Splash Loading' time to set the variables within the ini so that I do
not have to keep reading the values within them.

I'm still in the early stage of learning VBA so have no idea on how to do
this. Could someone offer any advice on what to do?

Many thanks,

Mark
Jul 8 '06 #1
3 1436
Bri
Mark Reed wrote:
All,
I have built a database recently which resides on a network server which
is constantly being re-structured. This is something I have no control over
so have had to incorporate a means by which the backend moving will not
cause too much of a headache and anyone can fix.
I decided to use an INI file to store several variables which can and often
do change.
I've also added a logging procedure which writes events to a text file to
aid me with ironing bugs out. Every time an event occurs, the READ_INI
procedure is being called to find out paths and file names to write to which
seems a little inefficient to me.

I have a splash screen within the database and was thinking that I could use
the 'Splash Loading' time to set the variables within the ini so that I do
not have to keep reading the values within them.

I'm still in the early stage of learning VBA so have no idea on how to do
this. Could someone offer any advice on what to do?
Yes, reading in these values once at the start of the app is the way to
go. If you load them into a global variable then they will be accessable
from anywhere in the code. One downside to this is that if the code gets
'Ended' (ie untrapped error gives user the Debug or End option and they
hit End) then these values get dumped. Global variables are declared in
a Modual not in a forms code.

Air Code (in a Modual):

Option Compare Database
Option Explicit

Public stPath2BE as string

Function Whatever() as String
blah
blah
Stuff to read your INI file
End Function

Air Code (in your splash form):

Option Compare Database
Option Explicit

Private Sub On_Open(Cancel as Integer)
stPath2BE = Whatever()
End Sub
--
Bri

Jul 8 '06 #2
Cheers very much for the info Bri. After a little more research (Which I
should have done first), combined with your post, I came up with the
following which is called when the splash form is opened:
Option Compare Database
Option Explicit

Global NETWORK_DRIVE As String
Global LOG_DIRECTORY As String
Global LOG_FILE_EXTENS ION As String
Global ARCHIVE_DIRECTO RY As String
Global CUSTOM_INI_LOCA TION As String
Global XP_USERNAME As String
Global XP_COMPUTERNAME As String
Public Sub Init_Globals()
NETWORK_DRIVE = KEY_Value("Keys ", "network_drive" )
LOG_DIRECTORY = KEY_Value("keys ", "Log_directory" )
LOG_FILE_EXTENS ION = KEY_Value("keys ", "log_file_exten sion")
ARCHIVE_DIRECTO RY = KEY_Value("keys ", "archive")
CUSTOM_INI_LOCA TION = KEY_Value("keys ", "custom_ini ")
XP_USERNAME = fOSUserName
XP_COMPUTERNAME = Environ("Comput ername")

End Sub

My question is that there are some variables that I would like to set in the
same manner but I do not have the information available when the database is
first opened. Can I save setting the GLOBAL values until later and just set
them once the needed info is available?

If this is the case, is it just a matter of saying 'THIS_GLOBAL =
WHATEVER_IS_NOW _AVAILABLE' once I can reference the needed information?

TIA,

Mark

"Bri" <no*@here.comwr ote in message
news:9TTrg.1320 87$iF6.94032@pd 7tw2no...
Mark Reed wrote:
>All,
I have built a database recently which resides on a network server
which is constantly being re-structured. This is something I have no
control over so have had to incorporate a means by which the backend
moving will not cause too much of a headache and anyone can fix.
I decided to use an INI file to store several variables which can and
often do change.
I've also added a logging procedure which writes events to a text file to
aid me with ironing bugs out. Every time an event occurs, the READ_INI
procedure is being called to find out paths and file names to write to
which seems a little inefficient to me.

I have a splash screen within the database and was thinking that I could
use the 'Splash Loading' time to set the variables within the ini so that
I do not have to keep reading the values within them.

I'm still in the early stage of learning VBA so have no idea on how to do
this. Could someone offer any advice on what to do?

Yes, reading in these values once at the start of the app is the way to
go. If you load them into a global variable then they will be accessable
from anywhere in the code. One downside to this is that if the code gets
'Ended' (ie untrapped error gives user the Debug or End option and they
hit End) then these values get dumped. Global variables are declared in a
Modual not in a forms code.

Air Code (in a Modual):

Option Compare Database
Option Explicit

Public stPath2BE as string

Function Whatever() as String
blah
blah
Stuff to read your INI file
End Function

Air Code (in your splash form):

Option Compare Database
Option Explicit

Private Sub On_Open(Cancel as Integer)
stPath2BE = Whatever()
End Sub
--
Bri

Jul 10 '06 #3
Bri
Once the variable is declared Public (use Public vs Global as they are
the same thing, but Public is more consistant with other versions) it is
initialized to 0 for numbers, empty string for text, Nothing for object,
etc. You can assign a real value to it at any time. Doing them all in
one place makes it easier to track them down later.

--
Bri

Mark Reed wrote:
Cheers very much for the info Bri. After a little more research (Which I
should have done first), combined with your post, I came up with the
following which is called when the splash form is opened:
Option Compare Database
Option Explicit

Global NETWORK_DRIVE As String
Global LOG_DIRECTORY As String
Global LOG_FILE_EXTENS ION As String
Global ARCHIVE_DIRECTO RY As String
Global CUSTOM_INI_LOCA TION As String
Global XP_USERNAME As String
Global XP_COMPUTERNAME As String
Public Sub Init_Globals()
NETWORK_DRIVE = KEY_Value("Keys ", "network_drive" )
LOG_DIRECTORY = KEY_Value("keys ", "Log_directory" )
LOG_FILE_EXTENS ION = KEY_Value("keys ", "log_file_exten sion")
ARCHIVE_DIRECTO RY = KEY_Value("keys ", "archive")
CUSTOM_INI_LOCA TION = KEY_Value("keys ", "custom_ini ")
XP_USERNAME = fOSUserName
XP_COMPUTERNAME = Environ("Comput ername")

End Sub

My question is that there are some variables that I would like to set in the
same manner but I do not have the information available when the database is
first opened. Can I save setting the GLOBAL values until later and just set
them once the needed info is available?

If this is the case, is it just a matter of saying 'THIS_GLOBAL =
WHATEVER_IS_NOW _AVAILABLE' once I can reference the needed information?

TIA,

Mark
Jul 10 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2716
by: Snyke | last post by:
Hi. I have a command line script which works really fine, the only problem is that it take *really* long for the first output to be printed on screen. Since I also get some HTTP headers I'm suspecting that some sort of output buffering is used. How can I tell PHP to flush the buffer automatically (without using flush(); after every print or echo) and to remove the headers?
12
2233
by: dvumani | last post by:
I have C code which computes the row sums of a matrix, divide each element of each row with the row sum and then compute the column sum of the resulting matrix. Is there a way I can speed up the code in C: /* Here is the code */ // Table is "wij" int i, j; for(i = 0; i < N; ++i) {
9
3408
by: mfyahya | last post by:
Hi, I'm new to databases :) I need help speeding up select queries on my data which are currently taking 4-5 seconds. I set up a single large table of coordinates data with an index on the fields I use most frequently in select queries. The data is about 100MB and index is 80MB. The table has the following structure: CREATE TABLE `ptimes` ( `id` INT UNSIGNED NOT NULL , `rc` CHAR ( 1 ) UNSIGNED NOT NULL ,
10
1610
by: Timothy Graves | last post by:
I have a quick (pun intended) question for the guru's out there. I have a piece of code where I am validating the input of chancters into a cell in a datagrid. I am using the keypressed event to get the charcter that the user typed and then allowing it to be passed to the cell. Now here is the tricked part, I am also validating the values (max and min) so that the user does not input a invalid number (out of range ex. byte != 256). ...
2
1565
by: Robert Wilkens | last post by:
Ok... This may be the wrong forum, but it's the first place I'm trying. I'm new to C# and just implemented the 3-tier Distributed application from Chapter 1 (the first walkthrough) in the "Walkthrough" book that comes with Visual Studio .NET 2003 Enterprise Architect. My first observation is -- woah, is this thing slow. From the time I clicked "load" to the time I had a populated data set on the windows-based app was almost 5-10...
2
1260
by: OHM | last post by:
I was wondering about this topic and although I accept that different situations call for different solutions, but wondered are there any other solutions and whether has anyone carried out a comparison of the different methods for avoiding JIT. Further more, is there anything I should be considering before using NGEN? Better methods etc > TIA
5
1332
by: jcrouse | last post by:
I have a program that is an external viewer. It is launched with a hotkey from within another application. The program has 30 labels that can be displayed. Since the labels may not always be oriented the same as the Operating System I needed to use the Label_Paint event to PAINT the labels text if it not oriented the same as the operating system. I am trying to figure out a way to make this event happen faster or optimize it if possible. I...
5
1440
by: RobinAG | last post by:
Hello, I just split my database into front and back end. My front end users are experiencing really slow opening of forms. I've searched online for help speeding up forms, but I'm not sure what the best way is with my current setup. I've inherited the database from a previous programmer, and he set things up a little uniquely. Here's the deal: I have a main form that opens, listing in a subform all of the projects, with some top-level...
10
1317
by: ags5406 | last post by:
I've created an application that downloads data daily from a secure web site and stores that data in an Access database. Then there are different options for allowing the user to do keyword and date searches on the database and have the information displayed for them. Everything looks and functions great, my only real dissatisfaction with my application is the update time, which in my last test took about 45-46 minutes for 9800 records....
0
9799
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9646
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10548
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7758
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6954
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5627
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5794
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3081
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.