Login Method Example


In this example, the PI-Login dialog is added to the File/Login menu item.


Create a new Visual Basic project. Click on Menu Editor in the Tools menu and add a menu item with Caption = "File" and Name = "menu_File". Add another menu item with Caption = "Login" and Name = "menu_Login". Indent the second menu item and click OK.


Make a reference to the PI-SDK Dialogs and the PISDK Type Library. Paste the code into the Declarations section. Run the project.

Private Sub menu_Login_Click()

Dim Cxn As New PISDKDlg.Connections

Dim s As Server

Dim msg As String

On Error Resume Next

'Use all defaults except force the dialog to show;

'this also requires override to be true.

Set s = Cxn.Login(, , , True, True)

If Err.Number <> 0 Then

MsgBox Err.Description

Exit Sub

End If

msg = "Connected to server " & s.Name

'Check for error if s is not a valid server.

If Err.Number = 0 Then

MsgBox msg


MsgBox Err.Description

End If

End Sub



Enabling Operational Intelligence