|
<< Click to Display Table of Contents >>
CreateLink |
CreateLink(Property, Source, [BindType])
This method allows creating a Link with a property of an object. In case of success, this method returns the object created. Otherwise, a script error occurs and this method returns Nothing. This method contains the parameters Property, which specifies the name of the property to which this Link is created, Source, which specifies the name of a Link's source object, and BindType, which is optional and specifies the type of Link to create. If this parameter is omitted, then a Simple Link is created.
NOTES |
•Not all existing properties in an object allow creating Links. To check which properties allow this feature, go to the Links tab of an object's Properties Window. If a property is invalid for a Link, it does not exist, or it already contains a Link, then a script error occurs. •When the value of the Source parameter starts with a colon (:), this indicates that the path to an object already starts at the root, avoiding the need to resolve this path and therefore improving the performance of applications with many Links. |
Available options for the BindType parameter
Option |
Description |
|---|---|
0 - Simple Link |
In a Simple Link, its source value is copied to the property every time it changes |
1 - Bidirectional Link |
A Bidirectional Link works as a Simple Link, but when there is a variation in the property, its value is copied to the source, thus generating a two-direction Link |
2 - Analog Link |
An Analog Link specifies a conversion scale between the source variable and the property |
3 - Digital Link |
In a Digital Link, fixed or alternating values are set to the property, and these values are set according to whether the source is true or false |
4 - Table Link |
In a Table Link, users can specify conditions between the variable, the values, and the destination. On that table users can specify minimum and maximum values, as well as other configurations |
5 - Reverse Link |
A Reverse Link is a unidirectional Link from the property to the source |
6 - Multisource Link |
A Multisource Link is similar to a Table Link, except that each Link row allows retrieving its value from a different source |
In the next example, clicking the Command Button creates a Bidirectional Link to the value of an Internal Tag in the Text1 object, that is, configures the BindType parameter to the value 1 (one).
Sub CommandButton1_Click()
On Error Resume Next
Dim bndType, bndValue
bndType = 1 'Bidirectional Link
Set bndValue = Screen.Item("Text1").Links.Item("Value")
If bndValue Is Nothing Then
MsgBox "Creating a Bidirectional Link"
Set bndValue = Screen.Item("Text1").Links.CreateLink("Value", "Data.InternalTag1.Value", bndType)
Else
MsgBox "Text1 already contains a Link to " & bndValue.Source
End If
End Sub