Is there a way to find out if a textbox contains a certain word or sentance? Thank you
Yes, the InStr function.
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart! If topic has been resolved, please pull down the Thread Tools & mark it Resolved. Is VB consuming your life, and is that a bad thing??
If InStr(Text1.Text, "hello world") Then...
Tips, Examples & Tutorials: A valuable forum tool • Generate unique TreeView keys • TreeView with "open" and "closed folder" icons • Time code using GetTickCount • How to trap the Tab key • Scroll a form • NumberBox ActiveX control • Color a ListView row • An InputBox form • How to use SaveSetting and GetSetting • A program registration scheme • Spellcheck a Textbox • Resize controls • Open Windows Explorer at Last Visited Path • A Blackjack Game • Count lines of code • Private Message Viewer • Copy/Paste VB Code • Paste VB Code Add-In • Insert Procedure Names Add-In • A calculator for the game of Spider • My review of REALbasic 2008 • VB6 Debug Tutorial • Picture/Video Viewer • VBF Photo Contest Winners 2009 - 2016
by the way is there a way to make it so caps do not matter?
If InStr(UCase(Text1.Text), "HELLO WORLD") Then...
or Code: If InStr(1,Text1.Text,"X",vbTextCompare) Then MsgBox "The letter 'X' is in Text1!" End If That will take care of upper and lower case letters.
If InStr(1,Text1.Text,"X",vbTextCompare) Then MsgBox "The letter 'X' is in Text1!" End If
Forum Rules