OPC Browsing

GetListOfOPCServers

  • The GetListOfOPCServers Function returns a list of Registered OPC Servers from the Network Node as a String Array.
  • Returns empty String Array if no Registered Servers are found.
  • Returns Nothing if the OAS Service is not reachable.
  • NetworkNode is the name of the network node of the OAS Service to connect to. Leave blank for localhost connection.
  • Optional ErrorString will be set to Success when function is successful and an error message when in error.

VB

 Private Sub ButtonGetListOfOPCServers_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonGetListOfOPCServers.Click
        Cursor.Current = Cursors.WaitCursor
        Dim OPCServers() As String
        Dim OPCServer As String
        Dim ErrorString As String = ""
        ListBoxListOfOPCServers.Items.Clear()
        OPCServers = ModuleNetworkNode.OPCSystemsComponent1.GetListOfOPCServers(TextBoxNetworkNode.Text, ErrorString)
        If ErrorString = "Success" Then
            If OPCServers.GetLength(0) < 1 Then
                ListBoxListOfOPCServers.Items.Add("No OPC Servers Found")
            Else
                For Each OPCServer In OPCServers
                    ListBoxListOfOPCServers.Items.Add(OPCServer)
                Next
            End If
        Else
            MessageBox.Show(ErrorString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If
    End Sub 
    
   Private Sub ListBoxListOfOPCServers_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBoxListOfOPCServers.SelectedIndexChanged
        TextBoxOPCServer.Text = ListBoxListOfOPCServers.SelectedItem
        TextBoxReferencePath.Text = ""
    End Sub

C#

 private void ButtonGetListOfOPCServers_Click(object sender, System.EventArgs e)
              {
                     System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;
                     string[] OPCServers = null;
//INSTANT C# NOTE: Commented this declaration since looping variables in 'foreach' loops are declared in the 'foreach' header in C#:
//                   string OPCServer = null;
                     string ErrorString = "";
                     ListBoxListOfOPCServers.Items.Clear();
                     OPCServers = ModuleNetworkNode.OPCSystemsComponent1.GetListOfOPCServers(TextBoxNetworkNode.Text, ref ErrorString);
                     if (ErrorString == "Success")
                     {
                           if (OPCServers.GetLength(0) < 1)
                           {
                                  ListBoxListOfOPCServers.Items.Add("No OPC Servers Found");
                           }
                           else
                           {
                                  foreach (string OPCServer in OPCServers)
                                  {
                                         ListBoxListOfOPCServers.Items.Add(OPCServer);
                                  }
                           }
                     }
                     else
                     {
                           MessageBox.Show(ErrorString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     }
              }
 
              private void ListBoxListOfOPCServers_SelectedIndexChanged(object sender, System.EventArgs e)
              {
                     TextBoxOPCServer.Text = ListBoxListOfOPCServers.SelectedItem.ToString();
                     TextBoxReferencePath.Text = "";
              }
              

GetOPCBranches

  • The GetOPCBranches Function returns a list of Branches from the OPC Servers as a String Array.
  • Returns empty String Array if no Branches are found.
  • Returns Nothing if the OAS Service is not reachable.
  • NetworkNode is the name of the network node of the OAS Service to connect to. Leave blank for localhost connection.
  • OPCServer is the name of the OPC Server to browse.
  • ReferencePath is a string of the branches path to browse.
  • Optional ErrorString will be set to Success when function is successful and an error message when in error.

VB

 Private Sub ButtonGetOPCBranches_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonGetOPCBranches.Click
        Cursor.Current = Cursors.WaitCursor
        Dim OPCBranches() As String
        Dim OPCBranch As String
        Dim ErrorString As String = ""
        ListBoxOPCBranches.Items.Clear()
        OPCBranches = ModuleNetworkNode.OPCSystemsComponent1.GetOPCBranches(TextBoxOPCServer.Text, TextBoxReferencePath.Text, TextBoxNetworkNode.Text, ErrorString)
        If ErrorString = "Success" Then
            If OPCBranches.GetLength(0) < 1 Then
                
 "No OPC Branches Found"
            Else
                For Each OPCBranch In OPCBranches
                    ListBoxOPCBranches.Items.Add(OPCBranch)
                Next
            End If
        Else
            MessageBox.Show(ErrorString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If
 
    End Sub 
 
    
 Private Sub ListBoxOPCBranches_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBoxOPCBranches.SelectedIndexChanged
        TextBoxReferencePath.Text = ListBoxOPCBranches.SelectedItem
    End Sub

C#

  private void ButtonGetOPCBranches_Click(object sender, System.EventArgs e)
              {
                     System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;
                     string[] OPCBranches = null;
//INSTANT C# NOTE: Commented this declaration since looping variables in 'foreach' loops are declared in the 'foreach' header in C#:
//                   string OPCBranch = null;
                     string ErrorString = "";
                     ListBoxOPCBranches.Items.Clear();
                     OPCBranches = ModuleNetworkNode.OPCSystemsComponent1.GetOPCBranches(TextBoxOPCServer.Text, TextBoxReferencePath.Text, TextBoxNetworkNode.Text, ref ErrorString);
                     if (ErrorString == "Success")
                     {
                           if (OPCBranches.GetLength(0) < 1)
                           {
                                  // "No OPC Branches Found"
                           }
                           else
                           {
                                  foreach (string OPCBranch in OPCBranches)
                                  {
                                         ListBoxOPCBranches.Items.Add(OPCBranch);
                                  }
                           }
                     }
                     else
                     {
                           MessageBox.Show(ErrorString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     }
 
              }
 
              private void ListBoxOPCBranches_SelectedIndexChanged(object sender, System.EventArgs e)
              {
                     TextBoxReferencePath.Text = ListBoxOPCBranches.SelectedItem.ToString();
              }

GetOPCBranchesWithDisplayNames

  • The GetOPCBranchesWithDisplayNames Function returns a list of Branches from the OPC Servers both Display Names and Actual Names as a String Array.
  • Returns empty String Array if no Branches are found or if the OAS Service is not reachable.
  • OPCServer is the name of the OPC Server to browse.
  • ReferencePath is a string of the branches path to browse.
  • NetworkNode is the name of the network node of the OAS Service to connect to. Leave blank for localhost connection.
  • Optional ErrorString will be set to Success when function is successful and an error message when in error.

VB

 Private Sub ButtonGetOPCBranchesWithDisplayNames_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonGetOPCBranchesWithDisplayNames.Click
        Cursor.Current = Cursors.WaitCursor
        Dim OPCBranches() As String
        Dim OPCBranch As String
        Dim ErrorString As String = ""
        ListBoxOPCBranchesWithDisplayName.Items.Clear()
        OPCBranches = ModuleNetworkNode.OPCSystemsComponent1.GetOPCBranchesWithDisplayNames(TextBoxOPCServer.Text, TextBoxReferencePath.Text, TextBoxNetworkNode.Text, ErrorString)
        If ErrorString = "Success" Then
            If OPCBranches.GetLength(0) < 1 Then
                
 "No OPC Branches Found"
            Else
                For Each OPCBranch In OPCBranches
                    ListBoxOPCBranchesWithDisplayName.Items.Add(OPCBranch)
                Next
            End If
        Else
            MessageBox.Show(ErrorString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If
 
    End Sub 
 
 Private Sub ListBoxOPCBranchesWithDisplayName_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBoxOPCBranchesWithDisplayName.SelectedIndexChanged
        TextBoxReferencePath.Text = ListBoxOPCBranchesWithDisplayName.SelectedItem
    End Sub

C#

                 private void ButtonGetOPCBranchesWithDisplayNames_Click(object sender, System.EventArgs e)
              {
                     System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;
                     string[] OPCBranches = null;
//INSTANT C# NOTE: Commented this declaration since looping variables in 'foreach' loops are declared in the 'foreach' header in C#:
//                   string OPCBranch = null;
                     string ErrorString = "";
                     ListBoxOPCBranchesWithDisplayName.Items.Clear();
                     OPCBranches = ModuleNetworkNode.OPCSystemsComponent1.GetOPCBranchesWithDisplayNames(TextBoxOPCServer.Text, TextBoxReferencePath.Text, TextBoxNetworkNode.Text, ref ErrorString);
                     if (ErrorString == "Success")
                     {
                           if (OPCBranches.GetLength(0) < 1)
                           {
                                  // "No OPC Branches Found"
                           }
                           else
                           {
                                  foreach (string OPCBranch in OPCBranches)
                                  {
                                         ListBoxOPCBranchesWithDisplayName.Items.Add(OPCBranch);
                                  }
                            }
                     }
                     else
                     {
                           MessageBox.Show(ErrorString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     }
 
              }
 
              private void ListBoxOPCBranchesWithDisplayName_SelectedIndexChanged(object sender, System.EventArgs e)
              {
                     TextBoxReferencePath.Text = ListBoxOPCBranchesWithDisplayName.SelectedItem.ToString();
              }

GetOPCItems

  • The GetOPCItems Function returns a list of Items from the OPC Servers as a String Array.
  • Returns both the Display Name and Qualified Item Path of each OPC Item.
  • Returns empty String Array if no Items are found.
  • Returns Nothing if the OAS Service is not reachable.
  • NetworkNode is the name of the network node of the OAS Service to connect to. Leave blank for localhost connection.
  • OPCServer is the name of the OPC Server to browse.
  • ReferencePath is a string of the branches path to browse.
  • Optional ErrorString will be set to Success when function is successful and an error message when in error.

VB

 Private Sub ButtonGetOPCItems_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonGetOPCItems.Click
        Cursor.Current = Cursors.WaitCursor
        Dim OPCItems() As String
        Dim ErrorString As String = ""
        ListBoxOPCItems.Items.Clear()
        OPCItems = ModuleNetworkNode.OPCSystemsComponent1.GetOPCItems(TextBoxOPCServer.Text, TextBoxReferencePath.Text, TextBoxNetworkNode.Text, ErrorString)
        If ErrorString = "Success" Then
            If OPCItems.GetLength(0) < 1 Then
                ListBoxOPCItems.Items.Add("No OPC Items Found")
            Else
                ListBoxOPCItems.Items.AddRange(OPCItems)
            End If
        Else
            MessageBox.Show(ErrorString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If
    End Sub

C#

    private void ButtonGetOPCItems_Click(object sender, System.EventArgs e)
              {
                     System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;
                     string[] OPCItems = null;
                     string ErrorString = "";
                     ListBoxOPCItems.Items.Clear();
                     OPCItems = ModuleNetworkNode.OPCSystemsComponent1.GetOPCItems(TextBoxOPCServer.Text, TextBoxReferencePath.Text, TextBoxNetworkNode.Text, ref ErrorString);
                     if (ErrorString == "Success")
                     {
                           if (OPCItems.GetLength(0) < 1)
                           {
                                  ListBoxOPCItems.Items.Add("No OPC Items Found");
                           }
                           else
                           {
                                  ListBoxOPCItems.Items.AddRange(OPCItems);
                           }
                     }
                     else
                     {
                           MessageBox.Show(ErrorString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     }
              }
              

GetOPCItemsAll

  • The GetOPCItemsAll Function returns a list of all OPC Items from an OPC Server from the starting branch as a String Array.
  • Returns both the Display Name and the Qualified Item Path of each OPC Item.
  • Returns empty String Array if no Items are found or the OAS Service is not reachable.
  • OPCServer is the name of the OPC Server to browse.
  • ReferencePath is a string of the starting branch to browse. Leave blank if you want all items from the OPC Server
  • NetworkNode is the name of the network node of the OAS Service to connect to. Leave blank for localhost connection.
  • Optional ErrorString will be set to Success when function is successful and an error message when in error.

VB

 Private Sub ButtonGetOPCItemsAll_Click(sender As System.Object, e As System.EventArgs) Handles ButtonGetOPCItemsAll.Click
        Cursor.Current = Cursors.WaitCursor
        If TextBoxOPCServer.Text = "OPCSystems.NET" Then
            If MessageBox.Show("Continue with Getting All Items from OPCSystems.NET OPC Server?", "DirectOPC with OPCSystems.NET OPC Server browse all OPC Servers", MessageBoxButtons.YesNo, MessageBoxIcon.Question) <> Windows.Forms.DialogResult.Yes Then
                Exit Sub
            End If
        End If
        Dim OPCItems() As String
        Dim ErrorString As String = ""
        ListBoxAllOPCItems.Items.Clear()
        OPCItems = ModuleNetworkNode.OPCSystemsComponent1.GetOPCItemsAll(TextBoxOPCServer.Text, TextBoxReferencePath.Text, TextBoxNetworkNode.Text, ErrorString)
        If ErrorString = "Success" Then
            If OPCItems.GetLength(0) < 1 Then
                ListBoxAllOPCItems.Items.Add("No OPC Items Found")
            Else
                ListBoxAllOPCItems.Items.AddRange(OPCItems)
            End If
        Else
            MessageBox.Show(ErrorString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If
    End Sub 
	    
	    Private Sub ListBoxOPCItems_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBoxOPCItems.SelectedIndexChanged
        TextBoxOPCItem.Text = ListBoxOPCItems.SelectedItem.ToString
    End Sub

C#

 private void ButtonGetOPCItemsAll_Click(object sender, System.EventArgs e)
              {
                     System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;
                     if (TextBoxOPCServer.Text == "OPCSystems.NET")
                     {
                           if (MessageBox.Show("Continue with Getting All Items from OPCSystems.NET OPC Server?", "DirectOPC with OPCSystems.NET OPC Server browse all OPC Servers", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != System.Windows.Forms.DialogResult.Yes)
                           {
                                  return;
                           }
                     }
                     string[] OPCItems = null;
                     string ErrorString = "";
                     ListBoxAllOPCItems.Items.Clear();
                     OPCItems = ModuleNetworkNode.OPCSystemsComponent1.GetOPCItemsAll(TextBoxOPCServer.Text, TextBoxReferencePath.Text, TextBoxNetworkNode.Text, ref ErrorString);
                     if (ErrorString == "Success")
                     {
                           if (OPCItems.GetLength(0) < 1)
                           {
                                  ListBoxAllOPCItems.Items.Add("No OPC Items Found");
                           }
                           else
                           {
                                  ListBoxAllOPCItems.Items.AddRange(OPCItems);
                            }
                     }
                     else
                     {
                           MessageBox.Show(ErrorString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     }
              }
 
              private void ListBoxOPCItems_SelectedIndexChanged(object sender, System.EventArgs e)
              {
                     TextBoxOPCItem.Text = ListBoxOPCItems.SelectedItem.ToString();
              }
 

GetOPCItemProperties

  • The GetOPCItemProperties Function returns the values for the properties of the OPC Item specified as an Object Array.
  • Returns the array of values for the properties specified.
  • The length of the array returned is always 6. The values returned within the array depend on if the property attributes are set to be returned.
  • Element 0 = Data Type.
    • 0 = Double Float
    • 1 = Single Float
    • 2 = Signed Byte
    • 3 = Unsigned Byte
    • 4 = Short Integer
    • 5 = Unsigned Short Integer
    • 6 = Integer
    • 7 = Unsigned Integer
    • 8 = Long Integer
    • 9 = Unsigned Long Integer
    • 10 = Boolean
    • 11 = String
    • 12 = Array Double
    • 13 = Array Integer
    • 14 = Array String
    • 15 = Array Single
    • 16 = Array Byte
    • 17 = Array Bool
    • 18 = Object Type
  • Element 1 = Scan Rate.
  • Element 2 = Description.
  • Element 3 = Units.
  • Element 4 = Enumated Value.
  • Element 5 = Enumartion Strings, each one seperated by semicolon.
  • Returns empty Object Array if the OPC Item is not found or the OAS Service is not reachable.
  • OPCItem is the name of the OPC Server and OPC Item to get the properties from. The syntax is OPCServerOPCItem.
  • ReturnDataType should be set to True to return the Data Type
  • ReturnScanRate should be set to True to return the Scan Rate
  • ReturnDescription should be set to True to return the Description
  • ReturnUnits should be set to True to return the Units
  • ReturnEnumeratedValue should be set to True to return the Is Enemurated Value and the Enumerated Strings
  • NetworkNode is the name of the network node of the OAS Service to connect to. Leave blank for localhost connection.
  • Optional ErrorString will be set to Success when function is successful and an error message when in error.

VB

 Private Sub ButtonGetOPCItemProperties_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonGetOPCItemProperties.Click
        Cursor.Current = Cursors.WaitCursor
        Dim OPCItemProperties() As Object
        Dim OPCItem As String = TextBoxOPCItem.Text
        Dim ErrorString As String = ""
        TextBoxDataType.Text = ""
        TextBoxScanRate.Text = ""
        TextBoxDescription.Text = ""
        TextBoxUnits.Text = ""
        TextBoxEnumeratedValue.Text = ""
        TextBoxEnumeratedValues.Text = ""
        OPCItemProperties = ModuleNetworkNode.OPCSystemsComponent1.GetOPCItemProperties(OPCItem, CheckBoxDataType.Checked, CheckBoxScanRate.Checked, CheckBoxDescription.Checked, CheckBoxUnits.Checked, CheckBoxEnumeratedValue.Checked, TextBoxNetworkNode.Text, ErrorString)
        If ErrorString = "Success" Then
            If OPCItemProperties.GetLength(0) < 6 Then
                MessageBox.Show("Invalid Length of Properties Array", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Else
                If CheckBoxDataType.Checked Then
                    Try
                        TextBoxDataType.Text = OPCItemProperties(0).ToString
                    Catch ex As Exception
                        MessageBox.Show("Cannot convert Data Type to String", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                    End Try
                End If
                If CheckBoxScanRate.Checked Then
                    Try
                        TextBoxScanRate.Text = OPCItemProperties(1).ToString
                    Catch ex As Exception
                        MessageBox.Show("Cannot convert Scan Rate to String", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                    End Try
                End If
                If CheckBoxDescription.Checked Then
                    Try
                        TextBoxDescription.Text = OPCItemProperties(2).ToString
                    Catch ex As Exception
                        MessageBox.Show("Cannot convert Description to String", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                    End Try
                End If
                If CheckBoxUnits.Checked Then
                    Try
                        TextBoxUnits.Text = OPCItemProperties(3).ToString
                    Catch ex As Exception
                        MessageBox.Show("Cannot convert Units to String", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                    End Try
                End If
                If CheckBoxEnumeratedValue.Checked Then
                    Try
                        TextBoxEnumeratedValue.Text = OPCItemProperties(4).ToString
                    Catch ex As Exception
                        MessageBox.Show("Cannot convert Enumerated Value to String", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                    End Try
                    Try
                        TextBoxEnumeratedValues.Text = OPCItemProperties(5).ToString
                    Catch ex As Exception
                        MessageBox.Show("Cannot convert Enumerated Values to String", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                    End Try
                End If
            End If
        Else
            MessageBox.Show(ErrorString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If
    End Sub

C#

         
                  private void ButtonGetOPCItemProperties_Click(object sender, System.EventArgs e)
              {
                     System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;
                     object[] OPCItemProperties = null;
                     string OPCItem = TextBoxOPCItem.Text;
                     string ErrorString = "";
                     TextBoxDataType.Text = "";
                     TextBoxScanRate.Text = "";
                     TextBoxDescription.Text = "";
                     TextBoxUnits.Text = "";
                     TextBoxEnumeratedValue.Text = "";
                     TextBoxEnumeratedValues.Text = "";
                     OPCItemProperties = ModuleNetworkNode.OPCSystemsComponent1.GetOPCItemProperties(OPCItem, CheckBoxDataType.Checked, CheckBoxScanRate.Checked, CheckBoxDescription.Checked, CheckBoxUnits.Checked, CheckBoxEnumeratedValue.Checked, TextBoxNetworkNode.Text, ref ErrorString);
                     if (ErrorString == "Success")
                     {
                           if (OPCItemProperties.GetLength(0) < 6)
                           {
                                  MessageBox.Show("Invalid Length of Properties Array", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                           }
                           else
                           {
                                  if (CheckBoxDataType.Checked)
                                  {
                                         try
                                         {
                                                TextBoxDataType.Text = OPCItemProperties[0].ToString();
                                         }
                                         catch (Exception ex)
                                         {
                                                MessageBox.Show("Cannot convert Data Type to String", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                         }
                                  }
                                  if (CheckBoxScanRate.Checked)
                                  {
                                         try
                                         {
                                                TextBoxScanRate.Text = OPCItemProperties[1].ToString();
                                         }
                                         catch (Exception ex)
                                         {
                                                MessageBox.Show("Cannot convert Scan Rate to String", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                         }
                                  }
                                  if (CheckBoxDescription.Checked)
                                  {
                                         try
                                         {
                                                TextBoxDescription.Text = OPCItemProperties[2].ToString();
                                         }
                                         catch (Exception ex)
                                         {
                                                MessageBox.Show("Cannot convert Description to String", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                         }
                                  }
                                  if (CheckBoxUnits.Checked)
                                  {
                                         try
                                         {
                                                TextBoxUnits.Text = OPCItemProperties[3].ToString();
                                         }
                                         catch (Exception ex)
                                         {
                                                MessageBox.Show("Cannot convert Units to String", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                         }
                                  }
                                  if (CheckBoxEnumeratedValue.Checked)
                                  {
                                         try
                                         {
                                                TextBoxEnumeratedValue.Text = OPCItemProperties[4].ToString();
                                         }
                                         catch (Exception ex)
                                         {
                                                MessageBox.Show("Cannot convert Enumerated Value to String", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                         }
                                         try
                                         {
                                                TextBoxEnumeratedValues.Text = OPCItemProperties[5].ToString();
                                         }
                                         catch (Exception ex)
                                         {
                                                MessageBox.Show("Cannot convert Enumerated Values to String", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                         }
                                  }
                           }
                     }
                     else
                     {
                           MessageBox.Show(ErrorString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     }
              }