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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

search in string

Status
Not open for further replies.

iainm

Technical User
Nov 28, 2001
67
0
0
AU
Couple of quick ones. I need a method to determine if one string is contained in another. Also, I can probably find this myself, but for the record, how do I get a simple Message/OK/Cancel-type dialog box?
cheers,
-IainM
 
1. instr(1,yourstring,yourstring2)
2. msgbox "YrMsg", vbOkCancel, YrPrgName
 
Hi,
You can use the InStr function to search for one string in another.

Eg.

If Instr(1,String to be searched,string searched for,vbBinaryCompare)<>0 then
' Code if string found
else
' code if string is not found
endif

Here the first arguemtn is used to specify the starting position for the search.


As for the message, you can use the MsgBox function. C

Ex.

if MsgBox(&quot;Do you want to continue?&quot;,vbOKCancel,&quot;Proceed?&quot;)=vbOK then
' Code if OK
else
' Code if not OK
endif


You can get the complete info on these using the Online help or MSDN.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top