From Xojo Documentation

Language Keyword

Identifies the global scope, making it possible to refer to items that might otherwise be ambiguous.




Global works similarly to Self, Me and Super and is most useful when working with namespaces. You use it to refer to a global identifier (such as a module or namespace) that might otherwise be inaccessible because they are hidden by local identifiers (i.e. methods or variables) in the current scope.

Sample Code

This example shows you how to access the Dictionary class within a method that has used Using to access Xojo.Core.Dictionary:

Using Xojo.Core
Dim d As New Dictionary // Uses Xojo.Core.Dictionary

Dim d2 As New Global.Dictionary // Uses Dictionary class

This is a more advanced example that shows how a local variable can make a module inaccessible:

Module Utility
Protected Version As Integer
End Module

Module AppStuff
Protected Version As String

Protected Sub GetStuff()
// Get the value of Utility.Version and assign it to our local Version
Version = Str(Utility.Version)

// But now we have a local variable named utility, which shadows module Utility!
Dim utility As Color

// In order to reach the Utility.Version, we must explicitly back out to the global scope
Global.Utility.Version = Val(utility.Hue)

// The first assignment can also be rephrased like this:
Global.AppStuff.Version = Str(Global.Utility.Version)
End Sub
End Module