Welcome to the forum.
Couple of typo's in your code.
Use "Nothing" instead of "NULL".
Use "pbDatasetPIExpression" instead of "pbDatasetExpression".
Get the Datasets from the Display level object "ThisDisplay".
Use Get/Set for Datasets to modify them.
Example:
Code:
Dim MyDatasets As Datasets
Set MyDatasets = ThisDisplay.Datasets
Dim MyDataset As PIExpressionDataset
Set MyDataset = MyDatasets.Add("NewCalcDataSet", Nothing, True, 1, True, pbDatasetPIExpression)
Set MyDataset = MyDatasets.GetDataset("NewCalcDataSet")
MyDataset.ServerName = "localhost"
MyDataset.Expression = "'sinusoid'*2"
MyDataset.RefreshInterval = 3600
MyDataset.ColumnName = "Value"
MyDataset.Interval = "10m"
MyDatasets.SetDataset MyDataset
Principal Consultant
Real-Time Data Management @ Wipro Technologies