[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 135
  • Last Modified:

Check part of a string

Hi guys,

How can i check part of string, for example, If a field contained the value "Carrots", I want to say: If value contains "Carr" then it will find carrots.

Thanks.

Mari
0
mari_carmen
Asked:
mari_carmen
  • 2
1 Solution
 
VbmasterCommented:
Check out the helpfile for the 'Like' statement, for example you can use it like this..

boolean value = String Like "Carr*"   -> if String = "Carrots" this will return True
0
 
Erick37Commented:
Use InStr() function

Dim sString As String
sString = "Carrots"
If InStr(1, sString, "Carr", vbTextCompare) <> 0 Then
    'Found
Else
    'not found
End If
0
 
MirkwoodCommented:
I think this is what you mean

Private Sub Command1_Click()
    If (InStr(1, "carrots", "carr") > 0) Then
        MsgBox "Found"
    Else
        MsgBox "Not Found"
    End If
End Sub
0
 
Erick37Commented:
Mirkwood, please explain the difference.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now