I'm wondering how to go about multi-stating a rectangle so that when particular PI tags trigger, it changes color. The tricky part is that I need it to trigger based on String values and I don't see why you can't do that in VBA. I am quite new to VBA and the biggest problem I'm having is where to actually put the damn function once I've written it (I learnt to multi-state a Label using a different thread and want to apply the same logic, that thread is here: Create a multi-state of a value in a Form using VBA ). should it be written directly in ThisDisplay, or should I create a Class? below is what I have so far and it doesn't work. I've tried to create a class but it doesn't compile
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) ' Library containing sleep function Dim Flash As Boolean Dim tagnameAllBuffStat As String Dim tagvalueAllBuffStat As String Dim tag As PIPoint Dim mysrv As Server Flash = True Set mysrv = PISDK.Servers.Item("WAIOHistorianSandbox") tagnameAllBuffStat = mysrv.PIPoints("Perth.EasternRidge.AF.All_Buffer_Status") tagvalueAllBuffStat = mysrv.PIPoints(tagnameAllBuffStat).Data.Snapshot Public Function ErrorStatus(ByVal Flash) ' Infinite loop to flash between red and blue if statement is true (Multi-state) Do While Flash = True 'Set conditions for multi-state If buttonEasternRidge.BackgroundColor = RGB(0, 0, 128) And tagvalueAllBuffStat = "OK" Then Me.buttonEasternRidge.BackgroundColor = RGB(100, 0, 0) Else: Me.buttonEasternRidge.BackgroundColor = RGB(0, 0, 128) End If Sleep (300) DoEvents Loop End Function
Thanks for your help, let me know if you need more details.