PDA

Click to See Complete Forum and Search --> : Public Constants ???


RoundCow
Jan 6th, 2000, 05:20 AM
i have a question about something, i would think would be easy. for a while now i have been making invisible labels to store values, there has to be an easier way. How do i make a value that can be used by any function?

jritchie
Jan 6th, 2000, 05:25 AM
RoundCow, (as opposed to square cow l guess)

Declare a Global variable in a module calling right at the start of the project

e.g

basStart

Option Explicit
Global sCompanyName as String

Sub Main()

sCompanyName = "Acme Plumbing"

This will make the variable sCompanyName visible to all forms, modules, classes etc in your project. :)

Janitor
Jan 6th, 2000, 05:26 AM
You can declare either global variables or constants.

If you want them available to all forms/modules in your project, put this in any module.

Public Const Constant_Name = 1
Global Variable_Name As String

Declare them at the top of a form to make them global in that form alone.

RoundCow
Jan 6th, 2000, 05:40 AM
i put

Option Explicit
global scanstatus as String

in the declarations, and it didn't work... does it have to be in a bas?

RoundCow
Jan 6th, 2000, 05:42 AM
coo, i did it in a module and it worked fine. thanks guys.

KENNNY
Jan 6th, 2000, 06:30 AM
whats the diff between Public and Global?
cos variables declared with Public in a module are also visible throughtout the project.

------------------
cintel rules :p
www.cintelsoftware.co.uk

Mark Sreeves
Jan 6th, 2000, 03:37 PM
Global is an outdated (vb3?)keyword but does the same as Public

KENNNY
Jan 6th, 2000, 07:32 PM
ah ha :)

------------------
cintel rules :p
www.cintelsoftware.co.uk