Answers for "excelvba declare global constant"

VBA
22

excelvba declare global constant

'In VBA, GLOBAL variables must be declared ABOVE all procedures in a module:

Public MyGlobalString As String				'<-- global to ALL modules
Private MyGlobalLong As Long				'<-- global to THIS module (Private)
Public Const HELP As String = "Press F1"	'<-- global to ALL modules

Sub Add(a, b)
	MyGlobalLong = a + b
End Sub

Call Add(7, 2)			
MsgBox MyGlobalLong		'<--displays: 9
MsgBox Help				'<--displays: Press F1

'
'
'
Posted by: Guest on March-30-2020

Code answers related to "excelvba declare global constant"

Code answers related to "VBA"

Browse Popular Code Answers by Language