Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 154
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 154
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Text "comparison" operator for "contains" used in an "IF" Function Pawaso Excel Worksheet Functions 4 April 4th 23 11:35 AM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
HELP!!! Promelem with InStr(1, c, Sheets("TEG").Cells(i, 18), 1) Ayo Excel Programming 5 November 13th 07 06:12 PM
inserting a conditional "go to" command on a excel "if" function velasques Excel Worksheet Functions 5 March 10th 06 08:16 PM
Please add a "sheet" function like "row" and "column" functions Spreadsheet Monkey Excel Programming 2 November 8th 05 04:08 PM


All times are GMT +1. The time now is 01:31 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"