Hi to all I am new to VBA I did some plain VBA a very long time ago but now I am trying to do it with FT SE an Rockwell makes it hard.
I am trying to get the user to input a number on the HMI to keep the project minimized for that length of time. When I first did the code I just kept the screen minimized for 30 seconds which sometimes we need longer so I tried this and it works but has one problem.
Now it does work but the problem is I enter the number the first time in the plc everything is good the bit are set correctly but it will not minimize. If I enter a number a second time then it will minimize then after the time entered it will maximize again. This happens all the time I have to do it twice to get it to work. I have stepped through the program and it worked great but when I run it as a project that is when I have the problem.
I would appreciate any help please like I said I am new to getting VBA stuff to work with Rockwell.
Thank-you
Craig
Here is my code.
Private Sub NumericInput1_Change()
On Error GoTo ErrorHandler
If Not IsError(NumericDisplay1.Value) Then
If NumericDisplay1.Value = 1 Then
Dim testString1 As String, localTags, testing
Set localTags = Application.CreateTagGroup(Me.AreaName)
localTags.Add "{[PAL2]ActiveScreen1[0]}"
localTags.Add "{[PAL2]ActiveScreen1[5]}"
localTags.Add "{[PAL2]ActiveScreen1[4]}"
testString2 = "" & localTags.Item(2).Value
testString1 = "" & localTags.Item(1).Value
testString3 = "" & localTags.Item(3).Value
On Error GoTo ErrorHandler
If Not IsError(NumericInput1.Value) Then
If testString3 = 1 Then
PauseTime = testString1
Start = Timer
Do While Timer < Start + PauseTime
DoEvents
Application.WindowState = gfxWindowStateMinimized
Loop
Finish = Timer
Application.WindowState = gfxWindowStateMaximized
End
End If
End If
Exit Sub
ErrorHandler:
LogDiagnosticsMessage Err.Description, ftDiagSeverityError
End If
End If
End Sub
I am trying to get the user to input a number on the HMI to keep the project minimized for that length of time. When I first did the code I just kept the screen minimized for 30 seconds which sometimes we need longer so I tried this and it works but has one problem.
Now it does work but the problem is I enter the number the first time in the plc everything is good the bit are set correctly but it will not minimize. If I enter a number a second time then it will minimize then after the time entered it will maximize again. This happens all the time I have to do it twice to get it to work. I have stepped through the program and it worked great but when I run it as a project that is when I have the problem.
I would appreciate any help please like I said I am new to getting VBA stuff to work with Rockwell.
Thank-you
Craig
Here is my code.
Private Sub NumericInput1_Change()
On Error GoTo ErrorHandler
If Not IsError(NumericDisplay1.Value) Then
If NumericDisplay1.Value = 1 Then
Dim testString1 As String, localTags, testing
Set localTags = Application.CreateTagGroup(Me.AreaName)
localTags.Add "{[PAL2]ActiveScreen1[0]}"
localTags.Add "{[PAL2]ActiveScreen1[5]}"
localTags.Add "{[PAL2]ActiveScreen1[4]}"
testString2 = "" & localTags.Item(2).Value
testString1 = "" & localTags.Item(1).Value
testString3 = "" & localTags.Item(3).Value
On Error GoTo ErrorHandler
If Not IsError(NumericInput1.Value) Then
If testString3 = 1 Then
PauseTime = testString1
Start = Timer
Do While Timer < Start + PauseTime
DoEvents
Application.WindowState = gfxWindowStateMinimized
Loop
Finish = Timer
Application.WindowState = gfxWindowStateMaximized
End
End If
End If
Exit Sub
ErrorHandler:
LogDiagnosticsMessage Err.Description, ftDiagSeverityError
End If
End If
End Sub