Simple VBA Script to change decimal settings of all values in a display

Blog Post created by MaxStrueverWipro on Mar 22, 2016

By request of a user, I needed to change all the values to show 3 decimal places in a given display.

The display had a ton of values, and I had to do it on several displays. I wanted to find an easier way to do this. After some messing around in VBA, I got this simple function to work:


Option Exclicit Public Sub decimals() 'set up some vars to be used     Dim symb As Symbol     Dim name As String     Dim typ As Integer     Dim tagname As String     Dim val As Value 'go through all symbols in a display     For Each symb In ThisDisplay.Symbols         name =         typ = symb.Type           'type 7 symbols are Values         If typ = 7 Then                  'get the name of the PI point (if you only want to change certain tags)                'format is \\servername\PointName             tagname = symb.GetTagName(1)                 'this will only change tags with the word 'temp' in the name, you can take this if statement out if you want to change all  values             If InStr(1, tagname, "temp") Then                'need to have a var of type Value to set the number format                 Set val = symb                'sets the formal to 3 decimals always                 val.NumberFormat = "0.000"             End If                      End If                            Next      End Sub




Added to github repo

GitHub - madmaxlax/helpful-OSIsoftProcessBookVBA: a collection of helpful VBA functions for ProcessBook