Error 1: replace "ipid2 = pdata;" with "ipid2 = (PISDK.IPIData2)pdata;" (you need an explicit conversion/cast)
Error 2: replace "asAverage, cbTimeWeighted" with "PISDK.ArchiveSummariesTypeConstants.asAverage, PISDK.CalculationBasisConstants.cbTimeWeighted". You'll also need to add a 6th parameter to the method, the PIAsyncStatus object (just pass null if you want to run this method synchronously)
Error 3: the error you are seeing here is because unlike in VB.NET, collection items are accessed with square brackets in C#. One might be tempted to simply replace "nvsSum("Average")" with "nvsSum["Average"]". In this case (it's a long story of COM vs. .NET interoperability), you will need to make use of the "get_Item" method and using the boxing/unboxing technique via an "object" object - see below:
object o = "Average";
valsum = (PISDK.PIValues)nvsSum.get_Item(ref o).Value;
Error 4: again, collection items are accessed using square brackets. Also, you will never get in the loop if you keep "i = 1; i < valsum.Count; i++": because the .Count will most likely be 1, you want to use "i = 1; i <= valsum.Count; i++".
Last but not least, you will need to use the .Value property to access the value on the PIValue object and put it in the textbox. Unlike VB6/VBA, .NET languages will not try to find some "default" value and throwing a whole PISDK.PIValue object in a TextBox' Text property will not work. Try this:
textBox1.Text = valsum.Value.ToString();
Hope this helps!
Thanks a lot steve,
its working now. :-)