Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
THE "INSTR" FUNCTION !!!
Hello -
Both combobox5 and textbox1 contain text strings. I am trying to determine if the string selected from the dropdown list in combobox5 is found in textbox1. If I use the following statement: If InStr(ComboBox5.Value, TextBox1.Value, vbBinaryCompare) 0 then .... I get the error: "Type mismatch." Any help with a better statement would be appreciated. Thanks! Jay *** Sent via Developersdex http://www.developersdex.com *** |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
THE "INSTR" FUNCTION !!!
If InStr(1,TextBox1.Text,ComboBox5.Text,vbTextCompare ) 0 Then
End If If this post helps click Yes --------------- Jacob Skaria "jay dean" wrote: Hello - Both combobox5 and textbox1 contain text strings. I am trying to determine if the string selected from the dropdown list in combobox5 is found in textbox1. If I use the following statement: If InStr(ComboBox5.Value, TextBox1.Value, vbBinaryCompare) 0 then .... I get the error: "Type mismatch." Any help with a better statement would be appreciated. Thanks! Jay *** Sent via Developersdex http://www.developersdex.com *** |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
THE "INSTR" FUNCTION !!!
The InStr function has a strange syntax in that it has an optional first and
fourth argument (an optional first argument is very unusual). Normally, one uses the default values for the optional arguments (specifying only the text to search and the string to look for). The first argument can be specified if need be without having to specify the fourth argument; HOWEVER, if you plan to specify the fourth argument, you MUST specify the first one as well. So, as Jacob posted, your statement needs to look like this... If InStr(1, ComboBox5.Value, TextBox1.Value, vbBinaryCompare) 0 Then. I would note that, UNLESS you used an Option Compare statement in your code module to change it, Binary comparisons are the default meaning that you would not have to explicitly specify vbBinaryCompare to get a Binary comparison. So, if you don't have an Option Compare statement active, you should be able to just do this... If InStr(ComboBox5.Value, TextBox1.Value) 0 Then -- Rick (MVP - Excel) "jay dean" wrote in message ... Hello - Both combobox5 and textbox1 contain text strings. I am trying to determine if the string selected from the dropdown list in combobox5 is found in textbox1. If I use the following statement: If InStr(ComboBox5.Value, TextBox1.Value, vbBinaryCompare) 0 then .... I get the error: "Type mismatch." Any help with a better statement would be appreciated. Thanks! Jay *** Sent via Developersdex http://www.developersdex.com *** |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
THE "INSTR" FUNCTION !!!
Okay, thanks Jacob and Rick! Is it possible to use the EXCEL functions,
"FIND()" and "SEARCH()" to achieve the same goal when dealing with a combobox and a textbox? If so, how will the statement be like? I am just curious !! Thanks! Jay *** Sent via Developersdex http://www.developersdex.com *** |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
THE "INSTR" FUNCTION !!!
It is more efficient to use the built-in VB functions that reaching out to
the worksheet functions (unless the worksheet functions provide a functionality that is not in VB and can't easily be coded for). Also, sometimes it can be a pain to properly construct the arguments for the worksheet functions from within VB. In any event, you can use the worksheet function by using the WorksheetFunction property of the Application object. -- Rick (MVP - Excel) "jay dean" wrote in message ... Okay, thanks Jacob and Rick! Is it possible to use the EXCEL functions, "FIND()" and "SEARCH()" to achieve the same goal when dealing with a combobox and a textbox? If so, how will the statement be like? I am just curious !! Thanks! Jay *** Sent via Developersdex http://www.developersdex.com *** |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Text "comparison" operator for "contains" used in an "IF" Function | Excel Worksheet Functions | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
HELP!!! Promelem with InStr(1, c, Sheets("TEG").Cells(i, 18), 1) | Excel Programming | |||
inserting a conditional "go to" command on a excel "if" function | Excel Worksheet Functions | |||
Please add a "sheet" function like "row" and "column" functions | Excel Programming |