Dokumentaro de Gambaso
Compilation & Installation
Components
Documents
Indekso de Lingvo
Language Overviews
LeguMin
Lexicon
Component
Gambaso
Registro

object

An object is a data structure that provides properties, variables, methods and events.

Each object is associated with a Class, that describes the behaviour of these properties, variables, methods and events.

A Class may be defined either in Gambas, as in the class "textbox", or by the programmer who defines a new class in their project.

A class never has an address. A class cannot be displayed.

Objects have a runtime address. This address can be displayed in the watch window. Members of the object can also be displayed in the watch window.

Example 1

In this example, "TextBox" is a Class. "TextBox1" is an Object which is created by the IDE. "hTextBox1" is a reference to an object of the type TextBox. Later in this example, the reference to the IDE created "TextBox1" is copied to "hTextBox1".

In the watch window of the IDE references to them show the same hexadecimal address. Members of the object can also be displayed in the watch window, e.g.:

Expression Value
TextBox ERROR: Unknown ...
TextBox1 (TextBox 0x81099c0)
hTextBox1 (TextBox 0x81099c0)
hTextBox1.Text "Set hTextBox1"

PUBLIC SUB Button1_Click()

DIM hTextBox1 AS TextBox            ' can hold the address of the object

hTextBox1 = TextBox1                ' gets the address of the already existing object
hTextBox1.Text = "Set hTextBox1"
hTextBox1.= TextBox1.+ 80
hTextBox1.= TextBox1.+ 120
    
END

Example 2

In this example, "TextBox" is a Class. "hTextBox1" is an Object of this Class, which will be created on the Form Form1. The TextBox is placed on the form at the designated X and Y coordinates, is filled with the specified text, and is given the name TextBox1.

PUBLIC SUB Button1_Click()

DIM hTextBox1 AS TextBox            ' can hold the address of the object

hTextBox1 = NEW TextBox(Form1)      ' Instantiates a new TextBox, i.e. creates the object
hTextBox1.Text = "Set hTextBox1"
hTextBox1.= TextBox1.+ 80
hTextBox1.= TextBox1.+ 120
    
END