I could use some help comparing 2 values

Discussion created by Cyberjay350 on Jan 10, 2020
Latest reply on Jan 27, 2020 by TimCarmichael

I've been using a Pi page to monitor an increasing value and alerting with a .wav sound file when it reaches a preset point. 

I'm trying to compare that same value to another value and sound another alert when both values meet a greater than/less than condition.  I'm not having luck getting it right.


Any help would be appreciated!


Heres the code:


Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long

Private Const SND_ASYNC = &H1
Private Const SND_LOOP = &H8
Private Const SND_MEMORY = &H4
Private Const SND_NODEFAULT = &H2
Private Const SND_NOSTOP = &H10
Private Const SND_SYNC = &H0
Private Const SND_ALIAS = &H10000
Private Const SND_APPLICATION = &H80
Private Const SND_ALIAS_ID = &H110000
Private Const SND_FILENAME = &H20000
Private Const SND_NOWAIT = &H2000
Private Const SND_PURGE = &H40
Private Const SND_RESOURCE = &H40004

Dim SAlert As String


'If the reel diameter is above a certain value and the spool starter speed is below a certain value, then sound an alert.



Private Sub Value2_DataUpdate()

Dim dvalue As Double: dvalue = Value1.GetValue(vrdate, vrstatus)

Dim dvalue2 As Double: dvalue2 = Value2.GetValue(vrdate, vrstatus)

SAlert = "S:\CR Data\share\C Team\Blahnik Temp folder\Spool Starter.wav"
    If dvalue > 42 And dvalue2 < 5 Then
        PlaySound SAlert, 0, &H1
    End If

End Sub