|
-
Jun 10th, 2002, 10:29 AM
#1
Thread Starter
_______
Like Operator
Lets say I have a line like
************* ** 2345 Page 1 *****
how do I say if I find the word page then msgbox "Page"
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Jun 10th, 2002, 10:35 AM
#2
Frenzied Member
Here is a simple way.
VB Code:
Dim sStr As String
sStr = "************* ** 2345 Page 1 *****"
If InStr(1, sStr, "Page") > 0 Then
MsgBox "Page"
End If
-
Jun 10th, 2002, 10:36 AM
#3
Not sure what you mean, especially the like operator part but try:
Code:
Dim tmp as String
If instr(mystring," Page ") > 0 then
tmp = mid(mystring,instr(mystring," Page ") )
tmp = left(tmp,instr(tmp,"*")-1)
msgbox tmp,vbOkOnly
End if
-
Jun 10th, 2002, 10:37 AM
#4
Frenzied Member
Jim : You are just being a little neater than i am. And i must agree never Hardcode the way i just hardcoded my code.
-
Jun 10th, 2002, 07:44 PM
#5
Doing the same sort of thing with the Like operator:
VB Code:
MyString = "************* ** 2345 Page 1 *****"
MySearch = "Page"
If MyString Like "*" & MySearch & "*" Then MsgBox MySearch
The "*" wildcard character using Like means "any characters". Note that Like only tells you if the search string exists in the string. It doesn't tell you where the search string is located like InStr.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|