Skip to content

Properties

webweenie edited this page Sep 27, 2022 · 47 revisions

twinBASIC Properties

A property is an attribute of an object. Objects, such as controls, can have any number of attributes which can be set by using the appropriate property. For example, the TextBox control has a Text property that allows the TextBox to be populated.

Properties are accessed using dot notation, as shown in the example below, which sets the text property of the Text1 object to the string, Hello World!:

Text1.text = "Hello World!"

Properties can also be used on the other side of the equal sign. For example, the contents of a TextBox can be loaded into a variable for further processing:

Dim strMyText as String = Text1.text

Alignment

Data Type

CheckBox and RadioButton

Justifies the part of the CheckBox or RadioButton the user interacts with to the right or left of the caption text.

Note: The CheckBox and RadioButton only support the values for Left and Right. Assigning a value of Center will cause the control to be set to Left justification.

Anchors

Data Type

Description

There are four anchor properties, Left, Top, Right, and Bottom. Anchors the object to one or more of the container boundaries. For example, anchoring an object to the bottom and right will cause the object to remain the same distance from the bottom and right of the container as the container is resized.

Note: The Anchors property must be set using the properties window on the form builder page. It is read-only in code at runtime.

Appearance

Data Type

Description

Gets and sets the appearance of the object. There are two possible values, vbAppear3d and vbAppearFlat.

BackColor, ForeColor

Data Type

Description

Gets and sets the backcolor or foreground color property. The background and foreground colors can be set in the form property window or at runtime by using the RGB function. For example, to set the background color of an object with the name "object", the following code could be used:

object.backgroundcolor = rgb(255,0,0) will set the background color to red.

BorderStyle

Data Type

The BorderStyle property sets and gets the border style of the control.

ComboBox

The BorderStyle property is read-only at runtime and can only be set in the property window on the form designer tab.

Caption

Data Type

Description

Gets and sets the caption text. The caption is the text that is displayed on the control

Dock

Data Type

Description

Gets and sets the Dock property. The object can be undocked, docked against any one container edge, or set to fill the entire container. There are six potential values for the Dock property: VBDockNone, VBDockLeft, VBDockTop, VBDockRight, VBDockBottom, and VBDockFill.

Enabled

Data Type

Description

Gets and sets the Enabled property. The Enabled property enables or disables the object. Disabling the object keeps the object visible but disables it and usually turns it grey.

FontBold, FontItalic, FontStrikethru, FontUnderline

Data Type

The FontBold, FontItalic, FontStrikethru, FontUnderline properties are all read/write at runtime and turn the various font effects on or off.

FontName

Data Type

The FontName property can get or set the font for the text that displays in a control. If the font named in the FontName property does not exist on the user's computer, the default font will be used.

FontSize

Data Type

The FontSize property sets and gets the size of the font for the text in the control, in points.

Height and Width

Data Type

Description

Gets and sets the height or width, in pixels, of the object.

IntegralHeight

Data Type

The IntegralHeight property determines if the height of the list should be autosized, based upon the number of data rows in the list. Setting the property to True tells the control to automatically resize if necessary. The control's size will be fixed if the property is set to False.

Note: the IntegralHeight property is read-only during runtime. Use the property window on the form designer to set the property.

ItemData

Data Type

Parameters

The ItemData property holds extra data tied to the ListData. For example, if you want to populate a ComboBox with a list of people, you could save each person's identifying key in the ItemData. You can then access the person's key using the example code below.

Dim SelectedKey As Long = Combo1.ItemData(Combo1.ListIndex)

Left and Top

Data Type

Double

Description

Gets and sets the left or top position of the object, relative to the container, in pixels.

List

Data Type

Parameters

The List property is the array of data that populates the control.

Locked

Data Type

The Locked property sets or gets the edit status of the control. A locked control is visible, but cannot be edited through the user interface. Note: this is different than the disabled property which modifies how the contol looks, in addition to disabling it.

MousePointer

Data Type

Description

MousePointerConstant property. Gets and sets the look of the mouse pointer when the mouse is over the object.

Name

Data Type

The Name property is a unique name that identifies the object to the owner of the object. Names for Forms must be unique across the entire application. Names for controls must be unique within the form (class). The name is used to an object when invoking methods and properties, as shown in the code below in which the Text property for an object named "Text1" is being set to the string, "Hello World".

Text1.Text = "Hello World"

Sorted

Data Type

The Sorted Property sets and gets a boolean value indicating whether the elements of a control are sorted alphabetically automatically. Note: The Sorted property is read-only during run-time and can only be set on the properties window on the form designer.

Style

Data Type

  • dependent on the control

The Style property sets or gets a value that determines the behavior of the control and how it will display its data.

ComboBox

Data Type: ComboBoxConstants

The ComboBox can be set to hide the dropdown until it is opened by the user, show the dropdown all of the time, or to only allow a selection from the list.

ListBox

Data Type: ListBoxConstants

The ListBox can be set to just show the text, like a standard listbox, or with a checkbox next to each item.

TabIndex

Data Type

Description

Gets or sets the order in which each object receives focus when the tab key is pressed.

TabStop

Data Type

Description

Gets or sets the TabStop property, which causes the focus to stop on the control when the tab button is pressed and the object's TabIndex is the next in line. Setting this property to False will cause the object to be skipped when the tab key is pressed to move to the next object.

Tag

Data Type

Description

Gets or sets the tag property. The tag property can be used to store program specific data. It is not used by twinBASIC and is not visible to the end user.

Text

Data Type

The Text property

CommandButton

When a ComboBox is set to style vbComboBoxDropdown or vbComboBoxSimple, the Text property gets and sets the text displayed in the textbox portion of the control. When the style is set to vbComboBoxDropdownList, the property is read-only at run-time and will return the text of the selected item.

TextBox

The Text property returns the text in the TextBox. The Text property is limited 20 2048 characters, unless the MultiLine property is set to True, in which case the maximum length is about 32K

Value

Data Type

  • dependent on the control

CheckBox

Data Type: CheckBoxConstants

The Value property of the CheckBox sets and gets the check state of the control, i.e., Unchecked (default), Checked, or Grayed (dimmed).

CommandButton

Data Type: Boolean

The Value property of the CommandButton control gets and sets the state of the control, i.e., True indicates the button is chosen and False (default) indicates the button is not chosen. Note: setting the Value property to True in code will raise the button's Click event.

ScrollBar

Data Type: Long

The Value property of the HScrollBar and VScrollBar controls sets the position of the scrollbar. Note: Set the Max value to the maximum possible value first, then set the Value property. The scrollbar will display at a point along the bar that represents the percent Value is of Max.

OptionButton

Data Type: Boolean

The Value property of the Option button gets and sets which option button within a group is selected. True indicates the button is selected and False indicates the button is not selected.

Visible

Data Type

Description

Gets or sets the visible property. Setting the property to True will make the object appear on the screen. Setting it to false will force it to not be shown.

VisualStyles

Data Type

Description

Indicates whether the control will be drawn reflecting the current Windows OS theme.

WheelScrollEvent

Data Type

The WheelScrollEvent Property...

Clone this wiki locally