How do you create a conditional statment for if something is incrementing in VB.net?

B King 89 1 Reputation point
2022-06-08T20:07:10.557+00:00

I am very new to VB.net I am working on a project that needs to confirm whether or not the following conditions are met, any help is GREATLY appreciated.

If Parameter 1 is incrementing And Parameter 2 equals 0 And Parameter 3 is not incrementing And Parameter 4 is Changing but less than 200 Then Device is Happy & Healthy Otherwise Device is not Happy & Healthy

Below is what I have so far, but I know it's probably no where close.

IF ( (arg0 = arg0+) and (arg1 = 0) and ( (arg2 < 200) and (arg2 = arg2+) ) )
return "H&H"
else
return "Error"
End If

Developer technologies | VB
{count} votes

1 answer

Sort by: Most helpful
  1. LesHay 7,146 Reputation points
    2022-06-08T21:13:21.83+00:00

    Hi
    OK, try this stand alone example and see if it helps. Edit values as needed to test and clcik button for results.

    ' new test Project with:  
    ' Form1  
    ' Datagridview named DGV  
    ' Button1  
      
    Option Strict On  
    Option Explicit On  
    Public Class Form1  
     Dim V As New DataTable("Freddy")  
     Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load  
     ' set up a series of test values  
     With V  
     .Columns.Add("arg0", GetType(Integer))  
     .Columns.Add("arg1", GetType(Integer))  
     .Columns.Add("arg2", GetType(Integer))  
     .Columns.Add("arg3", GetType(Integer))  
     .Columns.Add("result", GetType(String))  
      
     .Rows.Add(22, 0, 11, 111)  
     .Rows.Add(23, 0, 11, 112)  
     .Rows.Add(24, 0, 10, 113)  
     End With  
     DGV.DataSource = V  
     End Sub  
     Function CheckThem(arg0 As Integer, arg1 As Integer, arg2 As Integer, arg3 As Integer) As String  
     ' need to choose appropriate initial values  
     Static arg0h As Integer = 0  
     Static arg1h As Integer = 0  
     Static arg2h As Integer = 1000  
     Static arg3h As Integer = -1  
      
     Dim ret As String = "Error"  
     If ((arg0 > arg0h) And (arg1 = 0) And ((arg2 <= arg2h) And arg3 <> arg3h And arg3 < 200)) Then ret = "H&H"  
     arg0h = arg0  
     arg1h = arg1 ' just for completeness  
     arg2h = arg2  
     arg3h = arg3  
     Return ret  
     End Function  
     Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click  
     For i As Integer = 0 To V.Rows.Count - 1  
     V(i)("result") = CheckThem(CInt(V(i)("arg0")), CInt(V(i)("arg1")), CInt(V(i)("arg2")), CInt(V(i)("arg3")))  
     Next  
     End Sub  
    End Class  
    

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.