Using wildcards to find number in a sentence

marysilvaramos

Registered User.
Local time
Yesterday, 18:56
Joined
Oct 22, 2012
Messages
25
Hi:

I should find the position of a number in a sentence and later extracted. The number is attached always to an "E". ie: E1, E2, E3,E4. The range of the number is 1-4. I have this until now:

X: InStr("E[#]",[Col1_Comment_1])

but it always return 0

Please, may you tell me where is the error?

Big thanks in advance,

Mary
 
I don't believe that the Instr() function will accept wild cards. You could use a loop, perhaps something along the lines of;
Code:
Dim srchStr As String
Dim I As Integer

For I = 1 to 4
     srchStr = "E" & I
          
          If Instr( srchStr, [Col1_Comment_1]) > 0 Then
               MsgBox " You have a match" [COLOR="Green"]'Replace with your action[/COLOR]
          End If
Next
 
Thanks John for the reply! Is there anyway to find the number in a query? I am using a query to get the value and use it in a formula.

Thanks

Mary
 
Given that you only have four combinations could you test for all four explicitly?
 
This expression returns the next character after the first letter E in the textfield.

Code:
Mid([textfield],Instr([textfield],"E") + 1, 1)

Limit the query to records where the digits 1 to 4 following an E by using this Where clause.

Code:
WHERE [textfield] Like "*E[1-4]*"
 
Thanks to both for the replies! I am testing both versions.

Thanks again for the help,

Mary
 

Users who are viewing this thread

Back
Top Bottom