finding numbers in RTB

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Cengiz Ulku

    finding numbers in RTB

    Hi,

    How can look for only the numbers in a RTB control?
    I know for instance how to search for a string by using: :

    Private Sub Command1_Click( )
    Dim FoundPos As Integer
    Dim FoundLine As Integer
    ' Find the text specified in the TextBox control.
    FoundPos = RichTextBox1.Fi nd(Text1.Text, , , rtfWholeWord)

    etc...
    End sub


    Thanks!
    --
    Cengiz Ulku
    cengizu@bluewin .ch


  • Rick Rothstein

    #2
    Re: finding numbers in RTB

    > How can look for only the numbers in a RTB control?[color=blue]
    > I know for instance how to search for a string by using: :
    >
    > Private Sub Command1_Click( )
    > Dim FoundPos As Integer
    > Dim FoundLine As Integer
    > ' Find the text specified in the TextBox control.
    > FoundPos = RichTextBox1.Fi nd(Text1.Text, , , rtfWholeWord)[/color]

    Describe what you mean by "look for"... what are you trying to do? Replace
    the numbers? Delete the numbers? Erase the numbers? Or simply highlight
    them? Although I don't have anything specific in mind, I suspect I'd
    approach some of the above differently from the others.

    Rick - MVP


    Comment

    • Cengiz Ulku

      #3
      Re: finding numbers in RTB

      Sorry firstly,....

      The question is just about highlighting all/every digits or numbers in a rtf
      file, As Microsoft Word does with its Advanced find method.

      I think I should create an array of numbers to be found/highlighted... If
      you have any examples..

      Its been already some time that I'm asking "a few" questions about RTB
      Control, but I'm now trying to realize a project (a personal project),
      precisely a Turkish Bible reader, and for that reason i'm collecting all
      useful things/ideas or methods that will/may guide me.

      Thanks in advance!
      --
      Cengiz Ulku
      cengizu@bluewin .ch



      "Cengiz Ulku" <cengizu@bluewi n.ch> wrote in message
      news:3f526399$1 _2@news.bluewin .ch...[color=blue]
      > Hi,
      >
      > How can look for only the numbers in a RTB control?
      > I know for instance how to search for a string by using: :
      >
      > Private Sub Command1_Click( )
      > Dim FoundPos As Integer
      > Dim FoundLine As Integer
      > ' Find the text specified in the TextBox control.
      > FoundPos = RichTextBox1.Fi nd(Text1.Text, , , rtfWholeWord)
      >
      > etc...
      > End sub
      >
      >
      > Thanks!
      > --
      > Cengiz Ulku
      > cengizu@bluewin .ch
      >
      >[/color]


      Comment

      • Rick Rothstein

        #4
        Re: finding numbers in RTB

        I'm afraid the RichTextBox doesn't have anything useful built in. Almost
        anything you try will be "slow". Here's a direct approach that may prove
        useful.

        With RichTextBox1
        .Visible = False
        For X = 0 To Len(.Text)
        .SelStart = X
        .SelLength = 1
        If .SelText Like "#" Then
        .SelColor = vbRed
        End If
        Next
        .Visible = True
        End With

        You'll notice all I'm doing to highlight the numbers is to change their
        color. The RichTextBox doesn't support disconnected selection groupings nor
        the changing of the backcolor of individual pieces of text. By the way, I'm
        using the Visible property to hide the scrolling that takes place while the
        routine is running (it's slower to watch it happening). However, if you want
        your users to "see something" while it is working, remove the two statements
        that set this property to False and then True.

        Rick - MVP

        "Cengiz Ulku" <cengizu@bluewi n.ch> wrote in message
        news:3f536043$1 _4@news.bluewin .ch...[color=blue]
        > Sorry firstly,....
        >
        > The question is just about highlighting all/every digits or numbers in a[/color]
        rtf[color=blue]
        > file, As Microsoft Word does with its Advanced find method.
        >
        > I think I should create an array of numbers to be found/highlighted... If
        > you have any examples..
        >
        > Its been already some time that I'm asking "a few" questions about RTB
        > Control, but I'm now trying to realize a project (a personal project),
        > precisely a Turkish Bible reader, and for that reason i'm collecting all
        > useful things/ideas or methods that will/may guide me.
        >
        > Thanks in advance!
        > --
        > Cengiz Ulku
        > cengizu@bluewin .ch
        >
        >
        >
        > "Cengiz Ulku" <cengizu@bluewi n.ch> wrote in message
        > news:3f526399$1 _2@news.bluewin .ch...[color=green]
        > > Hi,
        > >
        > > How can look for only the numbers in a RTB control?
        > > I know for instance how to search for a string by using: :
        > >
        > > Private Sub Command1_Click( )
        > > Dim FoundPos As Integer
        > > Dim FoundLine As Integer
        > > ' Find the text specified in the TextBox control.
        > > FoundPos = RichTextBox1.Fi nd(Text1.Text, , , rtfWholeWord)
        > >
        > > etc...
        > > End sub
        > >
        > >
        > > Thanks!
        > > --
        > > Cengiz Ulku
        > > cengizu@bluewin .ch
        > >
        > >[/color]
        >
        >[/color]


        Comment

        Working...