Results 1 to 7 of 7

Thread: Filtering a textbox

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2001
    Posts
    395

    Filtering a textbox

    I have a multi-line richtextbox which I want to filter between a min and max number of characters.

    The fields would be:

    txtMin
    txtMax
    rtbMyTextToFilter
    txtOutput
    cmdFilter

    What is the best way to do this?

    Thanks,

    Jon

  2. #2

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2001
    Posts
    395

    Re: Filtering a textbox

    Min field is for minimum number of characters.
    Max field is for maximum number of characters.
    rtbMyTextToFilter is richtextbox with the data in it.
    txtOutput will be a richtextbox field which will show the filtered data.
    cmdFilter is my command button, which when clicked will trigger the filter.

    Have I got my naming convention a bit wrong?

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2001
    Posts
    395

    Re: Filtering a textbox

    I am trying a simplified version of my previous request but its not working. My code is below:

    VB Code:
    1. Dim strFiltered As String
    2. Dim strCurrentRow As String
    3. Dim strFullData As String
    4. strFullData = Text4.Text
    5.  
    6.     For i = 1 To 10
    7.     strCurrentRow = Split(Text4, vbCrLf)
    8.         If Len(strCurrentRow) > 5 Or Len(strCurrentRow) < 10 Then
    9.         strFiltered = strFiltered & strCurrentRow
    10.         MsgBox strFiltered
    11.     End If
    12. Next i
    13.  
    14. MsgBox i

    When I try to read in the richtextbox data (Text4) it doesn't just read in the text but all the rich text format data too. Hence, I think this is causing the problems.

    How can I read in just the text and not the rich text data?

  5. #5
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: Filtering a textbox

    Are you looking for something like:
    VB Code:
    1. Dim N As Long
    2. Dim row As String, rowes() As String, filtered As String
    3.     rowes = Split(Text4.Text, vbCrLf)
    4.         For N = 0 To UBound(rowes)
    5.             If Len(rowes(N)) > 5 And Len(rowes(N)) < 10 Then
    6.                 filtered = filtered & rowes(N) & vbCrLf
    7.             End If
    8.         Next N
    9.             If Len(filtered) Then filtered = Left(filtered, Len(filtered) - 2)
    10.                 MsgBox filtered
    ?

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2001
    Posts
    395

    Re: Filtering a textbox

    That's it! Thanks gavio.

  7. #7

Posting Permissions

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



Click Here to Expand Forum to Full Width