OPC Studio User's Guide and Reference
UAHostAndEndpointDialog Class
Members  Example 



OpcLabs.EasyOpcForms Assembly > OpcLabs.EasyOpc.UA.Forms.Browsing Namespace : UAHostAndEndpointDialog Class
Displays a dialog box from which the user can select a host (computer) and an endpoint of an OPC-UA server residing on it.
Object Model
UAHostAndEndpointDialog ClassEasyUAClientSelector ClassUADiscoveryElement ClassUAEndpointDescriptor ClassHostElement Class
Syntax
'Declaration
 
<CLSCompliantAttribute(True)>
<ComDefaultInterfaceAttribute(OpcLabs.EasyOpc.UA.Forms.Browsing.ComTypes._UAHostAndEndpointDialog)>
<ComVisibleAttribute(True)>
<GuidAttribute("0612DEF8-C143-45F4-A58F-C9C6A2B4AAA6")>
<TypeConverterAttribute(System.ComponentModel.ExpandableObjectConverter)>
<DesignerCategoryAttribute("Component")>
<SerializableAttribute()>
Public NotInheritable Class UAHostAndEndpointDialog 
   Inherits UADialog
   Implements OpcLabs.BaseLib.Forms.ComTypes._FormCommonDialog, OpcLabs.BaseLib.Forms.ComTypes._SizableCommonDialog, OpcLabs.BaseLib.Licensing.ILicensingContextHolder, OpcLabs.EasyOpc.UA.Forms.Browsing.ComTypes._UADialog, OpcLabs.EasyOpc.UA.Forms.Browsing.ComTypes._UAHostAndEndpointDialog, System.ComponentModel.IComponent, System.IDisposable 
'Usage
 
Dim instance As UAHostAndEndpointDialog
[CLSCompliant(true)]
[ComDefaultInterface(OpcLabs.EasyOpc.UA.Forms.Browsing.ComTypes._UAHostAndEndpointDialog)]
[ComVisible(true)]
[Guid("0612DEF8-C143-45F4-A58F-C9C6A2B4AAA6")]
[TypeConverter(System.ComponentModel.ExpandableObjectConverter)]
[DesignerCategory("Component")]
[Serializable()]
public sealed class UAHostAndEndpointDialog : UADialog, OpcLabs.BaseLib.Forms.ComTypes._FormCommonDialog, OpcLabs.BaseLib.Forms.ComTypes._SizableCommonDialog, OpcLabs.BaseLib.Licensing.ILicensingContextHolder, OpcLabs.EasyOpc.UA.Forms.Browsing.ComTypes._UADialog, OpcLabs.EasyOpc.UA.Forms.Browsing.ComTypes._UAHostAndEndpointDialog, System.ComponentModel.IComponent, System.IDisposable  
[CLSCompliant(true)]
[ComDefaultInterface(OpcLabs.EasyOpc.UA.Forms.Browsing.ComTypes._UAHostAndEndpointDialog)]
[ComVisible(true)]
[Guid("0612DEF8-C143-45F4-A58F-C9C6A2B4AAA6")]
[TypeConverter(System.ComponentModel.ExpandableObjectConverter)]
[DesignerCategory("Component")]
[Serializable()]
public ref class UAHostAndEndpointDialog sealed : public UADialog, OpcLabs.BaseLib.Forms.ComTypes._FormCommonDialog, OpcLabs.BaseLib.Forms.ComTypes._SizableCommonDialog, OpcLabs.BaseLib.Licensing.ILicensingContextHolder, OpcLabs.EasyOpc.UA.Forms.Browsing.ComTypes._UADialog, OpcLabs.EasyOpc.UA.Forms.Browsing.ComTypes._UAHostAndEndpointDialog, System.ComponentModel.IComponent, System.IDisposable  
Remarks

This is a modal dialog box; therefore, when shown, it blocks the rest of the application until the user has made a selection. When a dialog box is displayed modally, no input (keyboard or mouse click) can occur except to objects on the dialog box. The program must hide or close the dialog box (usually in response to some user action) before input to the calling program can occur.

 

General

Icon:

With UAHostAndEndpointDialog, your application can integrate a dialog box from which the user can select a host (computer) and an endpoint of OPC-UA server residing on it. This dialog box combines functions of the Computer Browser Dialog and OPC-UA Endpoint Dialog -  into a single dialog.

In addition, the user can add Host nodes in case the particular computer is not visible on the network, or add OPC-UA Endpoint nodes in case the OPC-UA Server is known to exist but is not returned by OPC-UA discovery feature.

Here is an example of OPC-UA Host and Endpoint dialog in action:

.NET

// This example shows how to let the user browse for a host (computer) and an endpoint of an OPC-UA server residing on it.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

using System.Windows.Forms;
using OpcLabs.EasyOpc.UA.Forms.Browsing;

namespace UAFormsDocExamples._UAHostAndEndpointDialog
{
    static class ShowDialog
    {
        public static void Main1(IWin32Window owner)
        {
            var hostAndEndpointDialog = new UAHostAndEndpointDialog
            {
                EndpointDescriptor = {Host = "opcua.demo-this.com"}
            };

            DialogResult dialogResult = hostAndEndpointDialog.ShowDialog(owner);
            if (dialogResult != DialogResult.OK)
                return;

            // Display results
            MessageBox.Show(owner, 
                $"HostElement: {hostAndEndpointDialog.HostElement}\r\n" +
                $"DiscoveryElement: {hostAndEndpointDialog.DiscoveryElement}");
        }
    }
}
# This example shows how to let the user browse for a host (computer) and
# an endpoint of an OPC-UA server residing on it.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
# OPC client and subscriber examples in PowerShell on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-PowerShell .
# Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
# a commercial license in order to use Online Forums, and we reply to every post.

using namespace OpcLabs.EasyOpc.UA.Forms.Browsing

# The path below assumes that the current directory is [ProductDir]/Examples-NET/PowerShell/Windows .
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcForms.dll"

# Instantiate the dialog object.
$hostAndEndpointDialog = New-Object UAHostAndEndpointDialog
$hostAndEndpointDialog.EndpointDescriptor.Host = "opcua.demo-this.com"

$dialogResult = $hostAndEndpointDialog.ShowDialog()
if ($dialogResult -ne [System.Windows.Forms.DialogResult]::OK) {
    return
}

# Display results
$hostElement = $hostAndEndpointDialog.HostElement
if ($hostElement -ne $null) {
    Write-Host "HostElement: $($hostElement)"
}
$discoveryElement = $hostAndEndpointDialog.DiscoveryElement
if ($discoveryElement -ne $null) {
    Write-Host "DiscoveryElement: $($discoveryElement)"
}
' This example shows how to let the user browse for a host (computer) and an endpoint of an OPC-UA server residing on it.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBNET .
' Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
' a commercial license in order to use Online Forums, and we reply to every post.

Imports OpcLabs.EasyOpc.UA.Forms.Browsing

Namespace UAFormsDocExamples._UAHostAndEndpointDialog
    Friend Class ShowDialog
        Shared Sub Main1(owner As IWin32Window)
            Dim hostAndEndpointDialog = New UAHostAndEndpointDialog() With {
                .EndpointDescriptor = New OpcLabs.EasyOpc.UA.UAEndpointDescriptor With {
                    .Host = "opcua.demo-this.com"
                    }
                }

            Dim dialogResult As DialogResult = hostAndEndpointDialog.ShowDialog(owner)
            If dialogResult <> DialogResult.OK Then
                Return
            End If

            ' Display results
            MessageBox.Show(owner,
                $"HostElement: {hostAndEndpointDialog.HostElement}" + Environment.NewLine +
                $"DiscoveryElement: {hostAndEndpointDialog.DiscoveryElement}")
        End Sub
    End Class
End Namespace

COM

// This example shows how to let the user browse for a host (computer) and an endpoint of an OPC-UA server residing on it.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

#include "stdafx.h"    // Includes "QuickOpc.h", and other commonly used files
#include "ShowDialog.h"

namespace _UAHostAndEndpointDialog
{
    void ShowDialog::Main()
    {
        // Initialize the COM library
        CoInitializeEx(NULL, COINIT_MULTITHREADED);
        {
            // 
            _UAHostAndEndpointDialogPtr HostAndEndpointDialogPtr(__uuidof(UAHostAndEndpointDialog));

            //
            HostAndEndpointDialogPtr->EndpointDescriptor->Host = L"opcua.demo-this.com";

            // 
            DialogResult dialogResult = HostAndEndpointDialogPtr->ShowDialog(NULL);
            _tprintf(_T("%d\n"), dialogResult);

            if (dialogResult == 1/*OK*/)
            {
                // Display results
                _HostElementPtr hostElementPtr = HostAndEndpointDialogPtr->HostElement;
                _tprintf(_T("HostElement: %s\n"), (hostElementPtr == NULL) ? _T("") : (LPCTSTR)CW2CT(hostElementPtr->ToString));
                _UADiscoveryElementPtr discoveryElementPtr = HostAndEndpointDialogPtr->DiscoveryElement;
                _tprintf(_T("DiscoveryElement: %s\n"), (discoveryElementPtr == NULL) ? _T("") : (LPCTSTR)CW2CT(discoveryElementPtr->ToString));
            }
        }
         // Release all interface pointers BEFORE calling CoUninitialize()
        CoUninitialize();
    }
}
// This example shows how to let the user browse for a host (computer) and
// an endpoint of an OPC-UA server residing on it.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

class procedure ShowDialog.Main;
var
  HostAndEndpointDialog: UAHostAndEndpointDialog;
begin
  // Instantiate the dialog object
  HostAndEndpointDialog := CoUAHostAndEndpointDialog.Create;

  HostAndEndpointDialog.EndpointDescriptor.Host := 'opcua.demo-this.com';

  HostAndEndpointDialog.ShowDialog(nil);
  // IMPROVE: check the dialog result

  // Display results
  // IMPROVE: check the nullness of HostAndEndpointDialog.HostElement
  WriteLn('HostElement: ', HostAndEndpointDialog.HostElement.ToString);
  // IMPROVE: check the nullness of HostAndEndpointDialog.DiscoveryElement
  WriteLn('DiscoveryElement: ', HostAndEndpointDialog.DiscoveryElement.ToString);
end;
// This example shows how to let the user browse for a host (computer) and
// an endpoint of an OPC-UA server residing on it.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in Object Pascal (Delphi) on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-OP .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

class procedure ShowDialog.Main;
var
  HostAndEndpointDialog: OpcLabs_EasyOpcForms_TLB._UAHostAndEndpointDialog;
  DialogResult: System_Windows_Forms_TLB.DialogResult;
  HostElement: OpcLabs_BaseLib_TLB.HostElement;
  DiscoveryElement: OpcLabs_EasyOpcUA_TLB.UADiscoveryElement;
begin
  // Instantiate the dialog object
  HostAndEndpointDialog := CoUAHostAndEndpointDialog.Create;

  HostAndEndpointDialog.EndpointDescriptor.Host := 'opcua.demo-this.com';

  DialogResult := HostAndEndpointDialog.ShowDialog(nil);
  WriteLn(DialogResult);

  if DialogResult <> DialogResult_OK then
    Exit;

  // Display results
  HostElement := HostAndEndpointDialog.HostElement;
  if HostElement <> nil then
    WriteLn('HostElement: ', HostElement.ToString);
  DiscoveryElement := HostAndEndpointDialog.DiscoveryElement;
  if DiscoveryElement <> nil then
    WriteLn('DiscoveryElement: ', DiscoveryElement.ToString);
end;
REM This example shows how to let the user browse for a host (computer) and an endpoint of an OPC-UA server residing on it.
REM
REM Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
REM OPC client and subscriber examples in Visual Basic on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VB .
REM Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
REM a commercial license in order to use Online Forums, and we reply to every post.

Private Sub ShowDialog_Main_Command_Click()
    OutputText = ""

    Dim HostAndEndpointDialog As New UAHostAndEndpointDialog
    HostAndEndpointDialog.endpointDescriptor.Host = "opcua.demo-this.com"
    
    Dim DialogResult
    DialogResult = HostAndEndpointDialog.ShowDialog
    
    OutputText = OutputText & DialogResult & vbCrLf
    If DialogResult <> 1 Then   ' OK
        Exit Sub
    End If
    
    ' Display results
    Dim HostElement As HostElement
    Set HostElement = HostAndEndpointDialog.HostElement
    If Not HostElement Is Nothing Then
        OutputText = OutputText & "HostElement: " & HostElement & vbCrLf
    End If
    Dim DiscoveryElement As UADiscoveryElement
    Set DiscoveryElement = HostAndEndpointDialog.DiscoveryElement
    If Not DiscoveryElement Is Nothing Then
        OutputText = OutputText & "DiscoveryElement: " & DiscoveryElement & vbCrLf
    End If
End Sub
Rem This example shows how to let the user browse for a host (computer) and an endpoint of an OPC-UA server residing on it.
Rem
Rem Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
Rem OPC client and subscriber examples in VBScript on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBScript .
Rem Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
Rem a commercial license in order to use Online Forums, and we reply to every post.

Option Explicit

Const DialogResult_OK = 1

Dim HostAndEndpointDialog: Set HostAndEndpointDialog = CreateObject("OpcLabs.EasyOpc.UA.Forms.Browsing.UAHostAndEndpointDialog")
HostAndEndpointDialog.EndpointDescriptor.Host = "opcua.demo-this.com"

Dim dialogResult: dialogResult = HostAndEndpointDialog.ShowDialog
WScript.Echo dialogResult

If dialogResult <> DialogResult_OK Then
    WScript.Quit
End If

' Display results
WScript.Echo "HostElement: " & HostAndEndpointDialog.HostElement
WScript.Echo "DiscoveryElement: " & HostAndEndpointDialog.DiscoveryElement

Python

# This example shows how to let the user browse for a host (computer) and an endpoint of an OPC-UA server residing on it.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
# OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python .
# Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
# a commercial license in order to use Online Forums, and we reply to every post.
# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from System.Windows.Forms import *
from OpcLabs.EasyOpc.UA.Forms.Browsing import *


hostAndEndpointDialog = UAHostAndEndpointDialog()
hostAndEndpointDialog.EndpointDescriptor.Host = 'opcua.demo-this.com'

dialogResult = hostAndEndpointDialog.ShowDialog()
print(dialogResult)
if dialogResult != DialogResult.OK:
    exit()

# Display results.
print('HostElement: ', hostAndEndpointDialog.HostElement, sep='')
print('DiscoveryElement: ', hostAndEndpointDialog.DiscoveryElement, sep='')

print('Finished.')

 

Advanced

If you want to change the parameters of the client object the component uses to perform its OPC operations, you can use the ClientSelector Property.

 

 

Example
// This example shows how to let the user browse for a host (computer) and an endpoint of an OPC-UA server residing on it.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

using System.Windows.Forms;
using OpcLabs.EasyOpc.UA.Forms.Browsing;

namespace UAFormsDocExamples._UAHostAndEndpointDialog
{
    static class ShowDialog
    {
        public static void Main1(IWin32Window owner)
        {
            var hostAndEndpointDialog = new UAHostAndEndpointDialog
            {
                EndpointDescriptor = {Host = "opcua.demo-this.com"}
            };

            DialogResult dialogResult = hostAndEndpointDialog.ShowDialog(owner);
            if (dialogResult != DialogResult.OK)
                return;

            // Display results
            MessageBox.Show(owner, 
                $"HostElement: {hostAndEndpointDialog.HostElement}\r\n" +
                $"DiscoveryElement: {hostAndEndpointDialog.DiscoveryElement}");
        }
    }
}
# This example shows how to let the user browse for a host (computer) and
# an endpoint of an OPC-UA server residing on it.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
# OPC client and subscriber examples in PowerShell on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-PowerShell .
# Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
# a commercial license in order to use Online Forums, and we reply to every post.

using namespace OpcLabs.EasyOpc.UA.Forms.Browsing

# The path below assumes that the current directory is [ProductDir]/Examples-NET/PowerShell/Windows .
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcForms.dll"

# Instantiate the dialog object.
$hostAndEndpointDialog = New-Object UAHostAndEndpointDialog
$hostAndEndpointDialog.EndpointDescriptor.Host = "opcua.demo-this.com"

$dialogResult = $hostAndEndpointDialog.ShowDialog()
if ($dialogResult -ne [System.Windows.Forms.DialogResult]::OK) {
    return
}

# Display results
$hostElement = $hostAndEndpointDialog.HostElement
if ($hostElement -ne $null) {
    Write-Host "HostElement: $($hostElement)"
}
$discoveryElement = $hostAndEndpointDialog.DiscoveryElement
if ($discoveryElement -ne $null) {
    Write-Host "DiscoveryElement: $($discoveryElement)"
}
' This example shows how to let the user browse for a host (computer) and an endpoint of an OPC-UA server residing on it.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBNET .
' Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
' a commercial license in order to use Online Forums, and we reply to every post.

Imports OpcLabs.EasyOpc.UA.Forms.Browsing

Namespace UAFormsDocExamples._UAHostAndEndpointDialog
    Friend Class ShowDialog
        Shared Sub Main1(owner As IWin32Window)
            Dim hostAndEndpointDialog = New UAHostAndEndpointDialog() With {
                .EndpointDescriptor = New OpcLabs.EasyOpc.UA.UAEndpointDescriptor With {
                    .Host = "opcua.demo-this.com"
                    }
                }

            Dim dialogResult As DialogResult = hostAndEndpointDialog.ShowDialog(owner)
            If dialogResult <> DialogResult.OK Then
                Return
            End If

            ' Display results
            MessageBox.Show(owner,
                $"HostElement: {hostAndEndpointDialog.HostElement}" + Environment.NewLine +
                $"DiscoveryElement: {hostAndEndpointDialog.DiscoveryElement}")
        End Sub
    End Class
End Namespace
// This example shows how to let the user browse for a host (computer) and an endpoint of an OPC-UA server residing on it.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

#include "stdafx.h"    // Includes "QuickOpc.h", and other commonly used files
#include "ShowDialog.h"

namespace _UAHostAndEndpointDialog
{
    void ShowDialog::Main()
    {
        // Initialize the COM library
        CoInitializeEx(NULL, COINIT_MULTITHREADED);
        {
            // 
            _UAHostAndEndpointDialogPtr HostAndEndpointDialogPtr(__uuidof(UAHostAndEndpointDialog));

            //
            HostAndEndpointDialogPtr->EndpointDescriptor->Host = L"opcua.demo-this.com";

            // 
            DialogResult dialogResult = HostAndEndpointDialogPtr->ShowDialog(NULL);
            _tprintf(_T("%d\n"), dialogResult);

            if (dialogResult == 1/*OK*/)
            {
                // Display results
                _HostElementPtr hostElementPtr = HostAndEndpointDialogPtr->HostElement;
                _tprintf(_T("HostElement: %s\n"), (hostElementPtr == NULL) ? _T("") : (LPCTSTR)CW2CT(hostElementPtr->ToString));
                _UADiscoveryElementPtr discoveryElementPtr = HostAndEndpointDialogPtr->DiscoveryElement;
                _tprintf(_T("DiscoveryElement: %s\n"), (discoveryElementPtr == NULL) ? _T("") : (LPCTSTR)CW2CT(discoveryElementPtr->ToString));
            }
        }
         // Release all interface pointers BEFORE calling CoUninitialize()
        CoUninitialize();
    }
}
// This example shows how to let the user browse for a host (computer) and
// an endpoint of an OPC-UA server residing on it.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in Object Pascal (Delphi) on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-OP .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

class procedure ShowDialog.Main;
var
  HostAndEndpointDialog: OpcLabs_EasyOpcForms_TLB._UAHostAndEndpointDialog;
  DialogResult: System_Windows_Forms_TLB.DialogResult;
  HostElement: OpcLabs_BaseLib_TLB.HostElement;
  DiscoveryElement: OpcLabs_EasyOpcUA_TLB.UADiscoveryElement;
begin
  // Instantiate the dialog object
  HostAndEndpointDialog := CoUAHostAndEndpointDialog.Create;

  HostAndEndpointDialog.EndpointDescriptor.Host := 'opcua.demo-this.com';

  DialogResult := HostAndEndpointDialog.ShowDialog(nil);
  WriteLn(DialogResult);

  if DialogResult <> DialogResult_OK then
    Exit;

  // Display results
  HostElement := HostAndEndpointDialog.HostElement;
  if HostElement <> nil then
    WriteLn('HostElement: ', HostElement.ToString);
  DiscoveryElement := HostAndEndpointDialog.DiscoveryElement;
  if DiscoveryElement <> nil then
    WriteLn('DiscoveryElement: ', DiscoveryElement.ToString);
end;
REM This example shows how to let the user browse for a host (computer) and an endpoint of an OPC-UA server residing on it.
REM
REM Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
REM OPC client and subscriber examples in Visual Basic on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VB .
REM Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
REM a commercial license in order to use Online Forums, and we reply to every post.

Private Sub ShowDialog_Main_Command_Click()
    OutputText = ""

    Dim HostAndEndpointDialog As New UAHostAndEndpointDialog
    HostAndEndpointDialog.endpointDescriptor.Host = "opcua.demo-this.com"
    
    Dim DialogResult
    DialogResult = HostAndEndpointDialog.ShowDialog
    
    OutputText = OutputText & DialogResult & vbCrLf
    If DialogResult <> 1 Then   ' OK
        Exit Sub
    End If
    
    ' Display results
    Dim HostElement As HostElement
    Set HostElement = HostAndEndpointDialog.HostElement
    If Not HostElement Is Nothing Then
        OutputText = OutputText & "HostElement: " & HostElement & vbCrLf
    End If
    Dim DiscoveryElement As UADiscoveryElement
    Set DiscoveryElement = HostAndEndpointDialog.DiscoveryElement
    If Not DiscoveryElement Is Nothing Then
        OutputText = OutputText & "DiscoveryElement: " & DiscoveryElement & vbCrLf
    End If
End Sub
Rem This example shows how to let the user browse for a host (computer) and an endpoint of an OPC-UA server residing on it.
Rem
Rem Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
Rem OPC client and subscriber examples in VBScript on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBScript .
Rem Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
Rem a commercial license in order to use Online Forums, and we reply to every post.

Option Explicit

Const DialogResult_OK = 1

Dim HostAndEndpointDialog: Set HostAndEndpointDialog = CreateObject("OpcLabs.EasyOpc.UA.Forms.Browsing.UAHostAndEndpointDialog")
HostAndEndpointDialog.EndpointDescriptor.Host = "opcua.demo-this.com"

Dim dialogResult: dialogResult = HostAndEndpointDialog.ShowDialog
WScript.Echo dialogResult

If dialogResult <> DialogResult_OK Then
    WScript.Quit
End If

' Display results
WScript.Echo "HostElement: " & HostAndEndpointDialog.HostElement
WScript.Echo "DiscoveryElement: " & HostAndEndpointDialog.DiscoveryElement
# This example shows how to let the user browse for a host (computer) and an endpoint of an OPC-UA server residing on it.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
# OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python .
# Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
# a commercial license in order to use Online Forums, and we reply to every post.
# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from System.Windows.Forms import *
from OpcLabs.EasyOpc.UA.Forms.Browsing import *


hostAndEndpointDialog = UAHostAndEndpointDialog()
hostAndEndpointDialog.EndpointDescriptor.Host = 'opcua.demo-this.com'

dialogResult = hostAndEndpointDialog.ShowDialog()
print(dialogResult)
if dialogResult != DialogResult.OK:
    exit()

# Display results.
print('HostElement: ', hostAndEndpointDialog.HostElement, sep='')
print('DiscoveryElement: ', hostAndEndpointDialog.DiscoveryElement, sep='')

print('Finished.')
Inheritance Hierarchy

System.Object
   System.MarshalByRefObject
      System.ComponentModel.Component
         System.Windows.Forms.CommonDialog
            OpcLabs.BaseLib.Forms.ConcreteCommonDialog
               OpcLabs.BaseLib.Forms.FormCommonDialog
                  OpcLabs.BaseLib.Forms.SizableCommonDialog
                     OpcLabs.EasyOpc.UA.Forms.Browsing.UADialog
                        OpcLabs.EasyOpc.UA.Forms.Browsing.UAHostAndEndpointDialog

Requirements

Target Platforms: .NET Framework: Windows 10 (selected versions), Windows 11 (selected versions), Windows Server 2016, Windows Server 2022; .NET: Linux, macOS, Microsoft Windows

See Also