AnsweredAssumed Answered

Multi-state multiple objects using VBA

Question asked by Mikeconnors on Jun 28, 2016

Hi All,

 

I currently face an issue where I would like to multi-state 6 buttons on the screen. Where I am having trouble is that multiple tags are linked to each button, some of which are strings. I have attempted to write a Do While loop where it constantly checks the values of each button but I can't get it to work.

 

I have used an If Else Then to try and trigger it however in that case, once a condition is found to be true, it will execute the corresponding code and not evaluate the conditions any further where i need it to continue evaluating. Does anyone know a way (preferably simpler than what I have) to be able to check statements and If it it true, make a button flash however continue to check other buttons? below is what I had written to try and explain a little better what I am trying to achieve. As most people can probably gather, when one of the ER

tag conditions is met, the rest of them aren't checked.

Private Sub ErrorStatus() 'if the statement below is false, Eastern Ridge button will flash  Call Define_Tags Flash = True  Do While Flash = True         If ERtagvalueAllInterfaceStat <> "OK" Or ERtagvalueAllBuffStat <> "OK" Or ERtagvalueLBS <> "OK" Or ERtagvalueCompRat < 20 Or ERtagvalueLowestArchiveSpace < 20 Or ERtagvalueBadValueRate > 20 Or ERtagvalueHighestInterface > 60 Then           buttonEasternRidge.FillColor = RGB(150, 0, 0)         ElseIf JBtagvalueAllInterfaceStat <> "OK" Or JBtagvalueAllBuffStat <> "OK" Or JBtagvalueLBS <> "OK" Or JBtagvalueCompRat < 20 Or JBtagvalueLowestArchiveSpace < 20 Or JBtagvalueBadValueRate > 20 Or JBtagvalueHighestInterface > 60 Then           buttonJimblebar.FillColor = RGB(150, 0, 0)         ElseIf WBtagvalueAllInterfaceStat <> "OK" Or WBtagvalueAllBuffStat <> "OK" Or WBtagvalueLBS <> "OK" Or WBtagvalueCompRat < 20 Or WBtagvalueLowestArchiveSpace < 20 Or WBtagvalueBadValueRate > 20 Or WBtagvalueHighestInterface > 60 Then           ButtonWhaleback.FillColor = RGB(150, 0, 0)         ElseIf YNtagvalueAllInterfaceStat <> "OK" Or YNtagvalueAllBuffStat <> "OK" Or YNtagvalueLBS <> "OK" Or YNtagvalueCompRat < 20 Or YNtagvalueLowestArchiveSpace < 20 Or YNtagvalueBadValueRate > 20 Or YNtagvalueHighestInterface > 60 Then           ButtonYandi.FillColor = RGB(150, 0, 0)         ElseIf PTtagvalueAllInterfaceStat <> "OK" Or PTtagvalueAllBuffStat <> "OK" Or PTtagvalueLBS <> "OK" Or PTtagvalueCompRat < 20 Or PTtagvalueLowestArchiveSpace < 20 Or PTtagvalueBadValueRate > 20 Or PTtagvalueHighestInterface > 60 Then           ButtonPort.FillColor = RGB(150, 0, 0)         ElseIf PEtagvalueLBS <> "OK" Or PTtagvalueLowestArchiveSpace < 20 Then           ButtonPerth.FillColor = RGB(150, 0, 0)         Else: buttonEasternRidge.FillColor = RGB(84, 188, 97)              buttonJimblebar.FillColor = RGB(84, 188, 97)              ButtonPerth.FillColor = RGB(84, 188, 97)              ButtonWhaleback.FillColor = RGB(84, 188, 97)              ButtonYandi.FillColor = RGB(84, 188, 97)              ButtonPort.FillColor = RGB(84, 188, 97)        End If        Sleep (300)        DoEvents Loop End Sub

 

I hope that makes sense, any other questions let me know,

 

Thanks!

 

Michael

Outcomes