Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Consecutive values between zero and one

Status
Not open for further replies.

Jeremiah32

Programmer
Jul 31, 2007
5
US
I found an array function that returns a true and false column values in a row are zero for mimumn of three consecutive times. Function works fine,, I was wondering cna the function be modified to identify consecutive values of zero or one? I'm working with a query that is linked with txt file.

thanks

Need to return a true value if consective values are 1,0,1 fales for 1,20,1

Public Function getConsecutive(ParamArray varValues() As Variant) As Boolean
Const intConsecutive = 3
Const intAmount = 0
Dim varVal As Variant
Dim intCount As Integer

For Each varVal In varValues
If Nz(varVal, 0) = 0 Then
intCount = intCount + 1
Else
intCount = 0
End If
If intCount = 3 Then Exit For
Next varVal
If intCount >= 3 Then getConsecutive = True
End Function
 
Replace this:
If Nz(varVal, 0) = 0 Then
with this:
If Nz(varVal, 0) = 0 Or Nz(varVal, 0) = 1 Then

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top