Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 16th, 2004, 08:16 AM
Authorized User
 
Join Date: Mar 2004
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to set a global variable?

Hi guys

When connecting for the first time, I want to hold the details of the database in global variables that can be accessed accross multiple modules, I know I can create public variables within a module but how do it do it across modules?

Many thanks for any help here!

Cheers

Ciaran
 
Old March 16th, 2004, 08:58 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If you create a public variable in a module (bas) you will be able to access that variable from anywhere within your project. Most of the time I use a global connection object.

Public gCn As ADODB.Connection

I then use a function in a dll/class module to connect to the database I pass the global connection object as a parameter.

Hope this helps.

Larry Asher
 
Old March 16th, 2004, 01:51 PM
Authorized User
 
Join Date: Mar 2004
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

Thanks for your help

Cheers

Ciaran





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to declare the global variable in global.asax? calyn_gately ASP.NET 3.5 Basics 0 August 6th, 2008 08:06 PM
how to set a global variable ckbseng ASP.NET 3.5 Basics 1 June 4th, 2008 08:44 AM
comapring global variable value to local variable amhicraig XSLT 6 December 5th, 2007 12:16 PM
Object variable or With block variable not set tparrish Classic ASP Databases 0 May 21st, 2005 06:48 AM
Object variable or with block variable not set spacy ASP.NET 1.x and 2.0 Application Design 0 September 21st, 2004 12:19 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.