Problems with the % character as search term

Results 1 to 2 of 2

Thread: Problems with the % character as search term

  1. #1
    Matthew Kirwan Guest

    Default Problems with the % character as search term

    Hi,<BR><BR>I have been developing a text search engine to search a database<BR>engine.<BR><BR>However I don&#039;t want users to include the % character in their search string as this will cause all records in the database to be retrieved.<BR><BR>As I result I tried using the following code to check whether there was a % character in the search string.<BR><BR>Line 1 charSearchCharacter = "%"<BR>Line 2 intPos = InStr(strKeywords, charSearchCharacter, 1)<BR><BR>However the code above when executed results in an error in Line 2<BR><BR>Microsoft VBScript runtime error &#039; 800a000d&#039;<BR>Type mismatch: &#039;[string:"%"]&#039;<BR><BR>In Line 1 I tried to using the HTML escape code for the % character &#37; but this didn&#039;t work.<BR><BR>Any ideas ?<BR><BR>Regards,<BR><BR>Matthew<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default Nope...problem using InStr function...

    Read the docs on InStr.<BR><BR>*** QUOTE ***<BR>InStr([start, ]string1, string2[, compare])<BR><BR>Arguments<BR>start -- Optional. Numeric expression that sets the starting position for each search. If omitted, search begins at the first character position. If start contains Null, an error occurs. The start argument is required if compare is specified.<BR>*** END QUOTE ***<BR><BR>REPEAT REPEAT REPEAT: The start argument is required if compare is specified. <BR><BR>In your code, you specified the compare argument (you tacked on the 1 as the third argument). Since you didn&#039;t then give a start argument, the system tried to take the first string as a number, etc.<BR><BR>Why did you specify the third argument? Since the character you are searching for ("%") isn&#039;t a letter, it wouldn&#039;t affect the search, anyway.<BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts