Reputation: 3
I have a 4 digit field that is constantly renewd and value changes. I need to print the field if the value in the field has changed more then 4 digits.
Example:
field_value=0111
if field_value=0112 (does not print)
if field_value=0116 (prints the value)
Upvotes: 0
Views: 238
Reputation: 38765
As I don't understand your spec - what exactly are your data and how do you measure the difference? - all I can give you is:
Option Explicit
Dim o : o = -1 ' definitely out of range
Dim n
For Each n In Split("0111 0112 0116 9990 9991 9995 9996")
n = CLng(n)
If 4 <= n - o Then
WScript.Echo o, n, "yes"
o = n ' <-- the important part
Else
WScript.Echo o, n, "no"
End If
Next
output:
cscript 25442674.vbs
-1 111 yes
111 112 no
111 116 yes
116 9990 yes
9990 9991 no
9990 9995 yes
9995 9996 no
If you can't specify the first out of range value or need to treat the first differently, you must use a counted loop.
Upvotes: 0