Search Text in a TextBox using IndexOf

Rather than using Regular Expression I want to know how I can use LastIndexOf and IndexOf to search for the Next and Previous match of a word typed. I want to use a TextBox and not a RichTextBox. Can someone provide me with a way to do this using loop so
it gets all the matches. I've got this so far:
Public Function FindAndSelect(TextToFind As String, MatchCase As Boolean) As Boolean
Dim mode = If(MatchCase, StringComparison.CurrentCulture, StringComparison.CurrentCultureIgnoreCase)
Dim position As Integer = textBox1.Text.IndexOf(TextToFind, mode)
If position = -1 Then
Return False
End If
textBox1.SelectionStart = position
textBox1.SelectionLength = TextToFind.Length
TextBox1.Select()
Return True
End Function
MessageBox.Show("Hey You!")

Rather than using Regular Expression I want to know how I can use LastIndexOf and IndexOf to search for the Next and Previous match of a word typed. I want to use a TextBox and not a RichTextBox. Can someone provide me with a way to do this using loop so
it gets all the matches. I've got this so far:
Public Function FindAndSelect(TextToFind As String, MatchCase As Boolean) As Boolean
Dim mode = If(MatchCase, StringComparison.CurrentCulture, StringComparison.CurrentCultureIgnoreCase)
Dim position As Integer = textBox1.Text.IndexOf(TextToFind, mode)
If position = -1 Then
Return False
End If
textBox1.SelectionStart = position
textBox1.SelectionLength = TextToFind.Length
TextBox1.Select()
Return True
End Function
MessageBox.Show("Hey You!")
Hello,
For Next, we could get that done with following way since we could select start index, you could refer to
String.IndexOf Method (String, Int32, StringComparison).
Dim startPostion As Integer = 0
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim str As String = "1"
' Dim mode = If(StringComparison.CurrentCulture, StringComparison.CurrentCultureIgnoreCase)
If startPostion + str.Length > TextBox1.Text.Count Then
Return
End If
Dim position As Integer = TextBox1.Text.IndexOf("1", startPostion, StringComparison.CurrentCultureIgnoreCase)
If position = -1 Then
Return
End If
TextBox1.SelectionStart = position
TextBox1.SelectionLength = str.Length
startPostion = position + str.Length
TextBox1.Select()
End Sub
The part about previous is quite similar, you could edit it to suit your scenario.
Regards,
Carl
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

  • How to search and replace a string in Excel Shape (textbox) using Powershell.

    I have been asked to write a PS script to search/replace a string when found in Excel Shapes when they are textboxes. I have seen lots of simplistic PS scripts and even I can do a "foreach" loop through all the Shapes on a Sheet and display the
    Name of each Shape. But I have not found a property or method to expose the actual text in a textbox let alone change it.
    I have seen vba script that does this as:  
    Set xWs = Application.ActiveWorkbook.Worksheets(I)
    For Each shp In xWs.Shapes
    xValue = shp.TextFrame.Characters.Text
    shp.TextFrame.Characters.Text = VBA.Replace(xValue, xFindStr, xReplace, 1)
    Next
    In Powershell, shp.TextFrame.Characters.Text is ignored and returns nothing.  It would be nice to know if this is possible in PS and if so, know how to do it and/or get an example to work from.  I would have thought that
    PS and VB would use the same Excel object model but apparently they do not.
    I am using Excel 14.0 and PS 3.
    Any suggestions would be appreciated,
    Michael

    This didn't work for me.  I have the shape object and it shows the textframe property:
    PS C:\> $shape | gm
       TypeName: System.__ComObject#{00024439-0000-0000-c000-000000000046}
    Name                       MemberType Definition
    Apply                      Method     void Apply ()
    CanvasCropBottom           Method     void CanvasCropBottom (float)
    SoftEdge                   Property   SoftEdgeFormat SoftEdge () {get}
    TextEffect                 Property   TextEffectFormat TextEffect () {get}
    TextFrame                  Property   TextFrame TextFrame () {get}
    TextFrame2                 Property   TextFrame2 TextFrame2 () {get}
    ThreeD                     Property   ThreeDFormat ThreeD () {get}
    But trying to access it gives an error:
    PS C:\> $shape.textframe | gm
    gm : You must specify an object for the Get-Member cmdlet.
    At line:1 char:20
    + $shape.textframe | gm
    +                    ~~
        + CategoryInfo          : CloseError: (:) [Get-Member], InvalidOperationException
        + FullyQualifiedErrorId : NoObjectInGetMember,Microsoft.PowerShell.Commands.GetMemberCommand
    PS C:\> $shape.TextFrame.Characters().text="hello"
    You cannot call a method on a null-valued expression.
    At line:1 char:1
    + $shape.TextFrame.Characters().text="hello"
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : InvokeMethodOnNull
    I hope this post has helped!

  • How to change the width of textbox in Search Texts iview

    Hi, Experts,
         I creat a search texts iview with stardard configuration to search the data in the repository.
    The problem is that the width of textbox is too short. And the user will input more than 40 characters in the textbox.
       In this way, the users can't see all the information unless he put the mouse pointer in the textbox and drag it.
       Is there any stardard configuration in MDM or MDM Portal to increase the width of textbox?
      Regards,
      Youli

    Hi Youli,
    I tried this but seems like there is no property available to change this setting. As these iViews are standard shipped, we cannot modify the design or code.
    Regards,
    Jitesh Talreja

  • Using Underscore In OIDDAS Group Search Text Box

    Hi Everyone,
    I am using the 'Directory' tab within the Oracle Self Service Console to search for user Groups.
    Most of my groups are of the form : PORT_xx_xxxx
    I am trying to search for all groups beginning PORT_ but if I enter that as a search query the underscore is treated as a single character wildcard. In my case this means the search results display PORT_xx_xxxx groups as well as a load of PORTAL_xxxx groups
    Is there a way to escape the underscore so that it is treated as a character and not a wildcard?
    If this was SQL then there is plenty of info out there about escaping underscores but nothing in relation to normal search text boxes.
    Matt

    Hi Luis,
    I tried PORT\_ but it still returns PORT_xx and PORTAL_xx results.
    I've got a feeling the text box filters out the usual escape characters making escaping the underscore impossible. It a bit annoying because it isn't as if the underscore is an unusual character to have in a group name!
    Matt

  • How fast text search field in Oracle without using Intermedia?

    How fast text search field in Oracle without using Intermedia? Thank you, Paul.

    yes,it is overriden in VOImpl
    public void executeQuery()
            setQuery((new StringBuilder()).append(selectStmt).append(" order by ").append(getOrderByClause()).toString());
            OAApplicationModuleImpl oaapplicationmoduleimpl = (OAApplicationModuleImpl)getApplicationModule();
            OAApplicationModuleImpl _tmp = oaapplicationmoduleimpl;
            if(oaapplicationmoduleimpl.isLoggingEnabled(1))
                OAApplicationModuleImpl _tmp1 = oaapplicationmoduleimpl;
                oaapplicationmoduleimpl.writeDiagnostics((new StringBuilder()).append(getClass().getName()).append(".executeQuery").toString(), (new StringBuilder()).append(" Query:").append(getQuery()).toString(), 1);
            super.executeQuery();
    But I have extended VO and substituted the VO . In the substituted VOImpl, instead of executeQuery(),I have written
    public void customExecuteQuery()
              setQuery((new StringBuilder()).append(selectStmt).append(" order by ").append(getOrderByClause()).toString());
              executeQuery();
    Will this work,or do I need to do any changes?
    Thanks,

  • Visio: Can't get Text Data in "Textboxes" to Export Properly using Reports or Databased Export Wizard

    Clarification: by textbox -- I mean a "text" shape created by using the "A Text" tool that appears in the ribbon. They are just free text boxes that are not associated w/
    any other shape.
    Hi. I am using Visio Professional 2010.  I am interested in extracting from each of my visio diagrams/drawings the text information that is shown in textboxes.
    I've tried using the Database Export Wizard and the Reports add-on; neither work. I've tried exporting to Excel and to Access.
    What I end up w/ is for some textboxes, the contained text is exported. But for other textboxes, nothing is exported or in some cases just a single letter/character is exported. I checked the number of characters in each textbox and all but one have fewer
    than 255 characters -- (if that makes a difference??). Some textboxes contain newline character (i.e., carriage returns). Does that make a difference?
    I've looked at previous questions and answers on the web and on this forum re. this topic and followed the proscribed advice, w/ no success. So any additional advice anyone can provide me, I would greatly appreciate it.
    Thanks -
    CJA

    Hey Chris,
    I tried exporting the text in visio drawing using database export wizard and found that yes the text which is associated with the sub group doesn't get exported.
    So the solution I think would work is that we have to write a macro which would read the shape.text property and it should check that if the shape is a group shape then it would check the sub shapes to get the text associated with them.
    You can refer to following msdn page to write this macro,
    msdn.microsoft.com/en-us/library/office/ff766497(v=office.15).aspx
    Let me know if you need further help to resolve your issue or if I have missed something.

  • Search Text Box

    I have a deliverable to display text in the search text box of the Top Bar view. When the user clicks the box to enter a search term, the initial string should be cleared allowing the user to type their term and perform a successful search. Here is the code I've tried but it doesn't work. The first line correctly sets the text box value to "Search Entire Portal". The second line is to clear the value when the text box is onFocus but this never happens, the initial string is still visible. Can anyone help?
    textBox.SetValue("Search Entire Portal");
    textBox.SetOnFocus("textBox.SetValue('');");

    Hi Elyssa,
    There are two problems here, one on your side and one on ours. The first problem is that in your SetOnFocus call, you use "textBox.SetValue('');" as the JavaScript code to execute. At runtime, the JavaScript doesn't know what "textBox" or "SetValue" are - these are Plumtree objects that are used to create the HTML source. What you need to use are JavaScript/DHTML/DOM methods. Instead of referring to "textBox", you can identify the HTML on the page by using it's id attribute. And instead of using "SetValue", you can use the standard "value" method. In this case, the id was created for you when the textBox was created:
    HTMLInput textBox = new HTMLInput(HTMLInputTypes.TEXT, factory.GetInputBoxName(), "");
    Given the id of the HTMLElement, you could do the following:
    textBox.SetValue("Search Entire Portal"); textBox.SetOnFocus(factory.GetInputBoxName() + ".value='';");
    I mentioned that there were two problems, however. The second problem is that our implementation of SetOnFocus has a bug in which it is not being written out to HTML. There are some options around this. If SetOnClick is enough, this works:
    textBox.SetValue("Search Entire Portal"); textBox.SetOnClick(factory.GetInputBoxName() + ".value='';");
    If the onclick event doesn't suit your needs, there is one way around this, though it's not very elegent. You can get the DisplayString from the textBox, modify this string by adding the onfocus="inputXXX.value='';" attribute, and then creating an HTMLGenericElement from this new string. You would then add this HTMLGenericElement to your cell instead of the textBox element.
    Hope that helps!

  • Verrrrryy Slloooow at search: text not found

    Hi, when i use the upper left quick-search-box (does that thing have a name?) and i hit a "text not found" it first displays a rectangular box over the textbox after 10 seconds (or something like that) the litte popup "Text not found" come's in.
    See images http://soffitta.cuijpers.it/shareimg/57997e1ed2020ff59e00c4f71f0ebf6a.png
    and http://soffitta.cuijpers.it/shareimg/4536ec106831af9ccf829f9a5667edf2.png
    It happens also when the search-text appears somewhere on the page before the cursor position.... This is very annoying because i use this search method a lot..
    btw i'm using 3.1 on osx (in oracle-look because the osx look keeps crashing :(....)
    Thanks in advance!

    Had the "Text not found" message a couple of times and was unable to dismiss it all together.
    Searching another text would display another popup message on top of the other. This last one could be dismissed, but the first one remained.
    Had to restart sqldev :-(
    Hope it's the same issue and that it gets bugged/fixed,
    K.

  • Searching up through a string with indexOf

    Hi all
    if i want to search for a pattern in a string then i use indexOf
    e.g.
    pos = text.indexOf(pattern, pos);
    if (pos>0)
    //string found
    that will search through a string from the current string position to the right until the string is found (ie searching down the string)
    how would i search up the string, so to find the previous occurance of the pattern and not the next one (ie searching up the string)

    Hope the following trivial code helps. It produces the following output
    4
    4
    4
    4
    9
    9
    4
    9
    4
    I believe this third pattern is what you'd be looking for.
    String rik = "HellHelloHelloHello";
    int pos = rik.indexOf("Hello");
    System.out.println(pos);
    pos = rik.indexOf("Hello", pos);
    System.out.println(pos);
    pos = rik.lastIndexOf("Hello", pos);
    System.out.println(pos);
    System.out.println("");
    pos = rik.indexOf("Hello");
    System.out.println(pos);
    pos = rik.indexOf("Hello", pos + 1);
    System.out.println(pos);
    pos = rik.lastIndexOf("Hello", pos);
    System.out.println(pos);
    System.out.println("");
    pos = rik.indexOf("Hello");
    System.out.println(pos);
    pos = rik.indexOf("Hello", pos + 1);
    System.out.println(pos);
    pos = rik.lastIndexOf("Hello", pos - 1);
    System.out.println(pos);

  • How search text in current frame of external swf?

    Hello Everyone
    I am loading an external swf using loader.
    How do search and highlight the text in the current frame only?
    Is there a frame class which I could use?
    Thanks

    This is not likely to be possible in the general case, depending on what you mean by "searching text"
    For instance, a Word doc might have the text "Hello, world!" when viewed in Word, but that doesn't mean that the sequence of characters 'H', 'e', 'l', 'l', 'o', etc., exists in the file. There might be one letter, then some binary data indicating that the next letter is some other font or color, then one more letter, then more binary data, etc.
    Conversely, there could be textual metadata in a "binary" file that a person reading the file in the appropriate viewer would never see. Unless you know the details of the format you're reading, you won't be able to distinguish that from "real text".
    And what do you mean "strings" is not efficient? Have you tried it? Does it do what you want? Did you measure and determine that it does not meet your well-defined performance requirements? It's unlikely you'll be able to write code that does the same thing as "strings" but more "efficiently."
    The first step is to put more realistic boundaries on your requirements and define them more precisely. "Extract text from any binary file," is not a valid, meaningful, or reasonable requirement.
    EDIT: I may have misunderstood your requirements. I thought you wanted to "extract all text" from binary files. If that's not what you meant, and you're looking more to replicate grep, then follow Joachim's advice.
    Edited by: jverd on Mar 29, 2010 1:33 PM

  • How to select and search text in this document?

    http://www.oracle.com/technology/products/manageability/database/pdf/ow05/PS_S003_274003_1 06-1_FIN_v2.pdf
    is a document I can read but cannot copy text from. I can't search for any text in it either. Is there a way to convert it to a PDF file I can select and search text in? What did the author do to make it "encrypted"? Thanks.
    Yong Huang

    I notice Google can convert it to plain text:
    http://74.125.95.132/search?q=cache:e4rkLs8pPekJ:www.oracle.com/technology/products/manage ability/database/pdf/ow05/PS_S003_274003_106-1_FIN_v2.pdf+understanding+shared+pool&cd=1&h l=en&ct=clnk&gl=us
    (If that long URL doesn't work, just search for "understanding shared pool" and click "View as HTML".)
    For now I'll use that. Thanks everyone.
    Also, my local desktop search program Copernic can also index keywords in the article.

  • Search text in all the labels in a panel (like control-F)

    hi,
    I have a Panel where I configure some preferences of the application. There ara about 200 preferences. (a preference is a JLabel plus a textfield/combobox/checkbox)
    I would like to know if someone has implemented something like control-F in browsers. The search should go through all the labels and highlight the label(s) that contain the text.
    thanks.

    You can use getComponents() method to get all components added to the Panel. Iterate through the array and check whether the current one is a JLabel instance. Then check JLabel's text and compare with the search string. If necessary label found highlight it (e.g. by changing text color or adding/removing colored line border). Then you can use the JLabel's bounds to make it visible in a scroll (if any).

  • Search text in PDF and MS Word document

    Can any body tell me how search text in PDF and MS Word document through Java code, any body has code or any suggestion to give
    Thank You
    Adnan

    Can any body tell me how search text in PDF
    and MS Word document through Java code, any
    body has code or any suggestion to giveYes.
    First, you need to work out how to read each document type from Java.
    E.g, for MS Word you could use Apache Jakarta POI - HWPF: http://jakarta.apache.org/poi/hwpf/index.html
    Then, you use Apache Lucene to index and search.
    See http://lucene.apache.org/java/docs/index.html
    ~D

  • Finding text in a PDF using preview has stopped working (correctly)

    Finding text in a PDF using preview has stopped working (correctly).
    When I search for certain words in a PDF using preview, it correctly finds all the pages in the document with that word.  However, it no longer highlights the word being searched for.  I have looked through the various settings and cannot figure out how to turn this back on.
    Thanks.

    4Shared worked, but having to register to retrieve files from there is a nuisance.
    The problem is that you use special graphic state operators inside text objects which is not allowed:
    BT
    /printmatic_F1 58.133398014634 Tf
    q
    /DeviceCMYK CS
    1 1 1 1 SCN
    /DeviceCMYK cs
    1 1 1 1 scn
    0.62060289801053 w
    0 J
    0 j
    2.189349112426 M
    0 Tr
    /printmatic_F1 58.133398014634 Tf
    1 0 0 1 86.448306387737 264.65046258267 cm
    (t) Tj
    Q
    q
    /DeviceCMYK CS
    1 1 1 1 SCN
    /DeviceCMYK cs
    1 1 1 1 scn
    0.62060289801053 w
    0 J
    0 j
    2.189349112426 M
    0 Tr
    /printmatic_F1 58.133398014634 Tf
    1 0 0 1 102.60939103581 264.65046258267 cm
    (e) Tj
    Q
    q
    /DeviceCMYK CS
    1 1 1 1 SCN
    /DeviceCMYK cs
    1 1 1 1 scn
    0.62060289801053 w
    0 J
    0 j
    2.189349112426 M
    0 Tr
    /printmatic_F1 58.133398014634 Tf
    1 0 0 1 134.93156033194 264.65046258267 cm
    (x) Tj
    Q
    q
    /DeviceCMYK CS
    1 1 1 1 SCN
    /DeviceCMYK cs
    1 1 1 1 scn
    0.62060289801053 w
    0 J
    0 j
    2.189349112426 M
    0 Tr
    /printmatic_F1 58.133398014634 Tf
    1 0 0 1 163.99825933926 264.65046258267 cm
    (t) Tj
    Q
    ET
    Have a look at the PDF specification ISO 32000-1:2008 (e.g. at http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf). Table 51 shows that q, Q, and cm are special graphics state operators, and Figure 9 illustrates that these operators, therefore, are not allowed in text objects, i.e. between BT and ET.

  • Can't include a reset button/process that cleans a search text field

    Hi all
    Using apex 3.0.1 on a XE edition
    In my app there's a report that displays a lot of records.
    I included an text field item, where user can type a search criteria, then i added a button called "search" which, when submitted, display the records where search criteria is included.
    Now, my problem is that i can't put a "reset" button, which, when submmitted, is supposed to clear the search text field, so the report display all records.
    I tried adding a branch that triggers when reset buttos is pressed, clearing cache of search text field. It didn't worked, search string keeps on showing on text field.
    Then i changed the process, instead of clearing cache, setting search text field item with a value of null. Didnt work either...
    Does anyone have a good example of thjis type of reset button???
    tnks in advance....
    Fernando

    yes Earl, i know it's pretty standard...but i got some trouble... anyway, i think it was just a "lapsus brutus" o' mine... It's solved now and here's what i did:
    I created a text field button (where search string will be typed), a "submit as Go" button, and a "submit as reset" button. Then i created an uncondicional branch to same page, then i created a Clear Cache for Item process, where the text field cache is cleared, conditioned when "submit as reset" button is pressed.
    That solved the problem, thnx very much for your help
    fernando

Maybe you are looking for