# Thread: Regular Expression, Check value between 0 and -100

1. ## Regular Expression, Check value between 0 and -100

HI,

How to use regular expression for the following scenario

I need to check if a value is in between 0 and -100. If the value is present in the range, report fail. If value less than -100 report pass.

I came up with this code
bResult=False
'If intProcessingCode &lt; "-100" Then
bResult = False
For i = -100 to 0
If intProcessingCode = i Then
' bResult = True
LogResult micFail, "Fail", "Processing Code=: " &amp;intProcessingCode, Nothing
Exit For
Else
bResult = False
End If
Next
' If strProcessingCode = i Then
If bResult = False Then
LogResult micPass, "Pass", "Processing Code=: " &amp;strProcessingCode, Nothing
End If

I did look for using a regular expression but could not find one. Can someone please help with this

Thanks

2. ## Re: Regular Expression, Check value between 0 and -100

Why not just check if (intProcessingCode &lt;= 0) and (intProcessingCode &gt;= -100)?

3. ## Re: Regular Expression, Check value between 0 and -100

Tried it but seems not giving the proper result
For example if intProcessingcode is -1381 I want to report is as a pass.
Any value between 0 and -100 (including 0 and -100) is a failure.

4. ## Re: Regular Expression, Check value between 0 and -100

iMax=0
iMin=-100
intProcessingCode=-1381
If intProcessingCode&gt;= iMin AND intProcessingCode&lt;=iMax Then
msgbox False
Else
msgbox True
End If
'' it works man

5. ## Re: Regular Expression, Check value between 0 and -100

You don't need regular expression in straight forward comparisons. This only need when the comparison needs some pattern matching

6. ## Re: Regular Expression, Check value between 0 and -100

Thanks for the code. When i run this code as it is, it's working fine. In my scenario, i need to get the ProcessingCode value from DB and check if the value is in between 0 and -100. When i execute the SQL query and get the processing code value, and use this piece of code somehow it's not giving the proper result.

For example if intProcessingCode value is -2, instead of showing "False ", it shows "True"

I came up with this piece of code that's working at the moment

blnResult = False

For intCode = -100 to 0
If strcomp(strProcessingCode, intCode)=0 Then
blnResult = True
LogResult micFail "" &amp;strProcessingCode, Nothing Exit For
Else
blnResult = False
End If
Next
If blnResult = False Then
LogResult micPass, "" &amp;strProcessingCode, Nothing
End If

7. ## Re: Regular Expression, Check value between 0 and -100

strProcessingCode = CInt(strProcessingCode)

Use to to make sure you convert the value to int

8. ## Re: Regular Expression, Check value between 0 and -100

Thanks Tarun. It works perfectly fine now.
Also many thanks to RedTest and NoUse4aName.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.