• Not Answered

VBA Radio Optionbutton animation

So I created a simple form with 4 radio optionbuttons.  When I open the form and select an option it writes a value to DVSYS.MOD/xxx.F_CV.  Once I close and reopen the vba script, I don't see the choice anymore, however, I can pick the same option to make the "darken" circle come up again.  It would mean that I am rewriting the same value back to the DeltaV side because the value has been written to a parameter already.  I tried to do a simple IF/THEN statement to read value from deltaV but it gives me an error.  Any suggestions on making the radio optionbuttons to be selected on the current value from the deltaV side?

Example below:

OptionButton4_Click()
Dim Result As VbMsgBoxResult
Result = MsgBox("Switchover?", vbOKCancel, "Selector Confirmation")
If Result = vbOK Then
writevalue "3", "DVSYS.MOD/xxx.F_CV"
End If
End Sub

Private Sub UserForm_Initialize()

If "DVSYS.MOD/XXX.F_CV" = 0 Then
OptionButton1 = True
End If

If "DVSYS.MOD/XXX.F_CV" = 1 Then
OptionButton2 = True
End If

If "DVSYS.MOD/XXX.F_CV" = 2 Then
OptionButton3 = True
End If

If "DVSYS.MOD/XXX.F_CV" = 3 Then
OptionButton4 = True
End If


End Sub

3 Replies

  • Try the following instead on the Initial Event:

    Dim curVal As Integer
    Dim lngError As Long

    curVal = frsReadValue("DVSYS.MOD/XXX.F_CV", lngError)
    If lngError = 0 Then 'Successfully Read Parameter
    Select Case curVal
    Case 0
    OptionButton1 = True
    Case 1
    OptionButton2 = True
    Case 2
    OptionButton3 = True
    Case 3
    OptionButton4 = True
    End Select
    End If
  • In reply to Matt Stoner:

    Thanks Matt, that worked nicely, but it resends the last command. In other words the message box will pop up again asking if you want to switch over when it is already in that option. Is there a way to read the value from DeltaV, then use that "curVal" to set the animation without restarting the "True" command on an option?
  • In reply to JackC:

    You would need to program the system to:
    - check if the value is different and only prompt and write if the value is different or something like that
    - only write the option selected when an Ack button is clicked so they could change the value many times and then only write when Ack it selected.