Features, discussions, tips, tricks, questions, problems and feedback

How to update elements using C# or VB / Set the values of tags

     DataElement de1 = DataElementEngine.NewDataElement("Adroit.A1.value");
     de1.Value = 3.14;  
     DataElement de2 = DataElementEngine.NewDataElement("Adroit.A2.value");
     de2.Value = 42; //<-- this could be retrieved from other controls on the form as well
     DataElementCollection dec = DataElementEngine.NewDataElementCollection();
     MethodReturnInfo info = MyConnection.UpdateDataElements(dec);
     if (!info.Success)
        MessageBox.Show("An error occurred whilst updating the value, the error was: " + info.ReturnInformation);
  catch (Exception ex)
     MessageBox.Show("An error occurred: " + ex.ToString());

Similar code but in VB:

    Dim de As DataElement = DataElements.Engine.DataElementEngine.NewDataElement("Adroit._SAMPLEEXPRESSION.v01")
    de.Value = 0

    Dim dec As DataElementCollection = DataElements.Engine.DataElementEngine.NewDataElementCollection()

    Dim info As MethodReturnInfo = MyConnection.UpdateDataElements(dec)
    If info.Success Then
        MessageBox.Show("Update of Adroit._SAMPLEEXPRESSION.v01 was successfull")
        MessageBox.Show("Update of Adroit._SAMPLEEXPRESSION.v01 has failed: " + info.ReturnInformation)
    End If