Results 1 to 13 of 13

Thread: [RESOLVED] Another Problem With Text Sentences

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Posts
    80

    Resolved [RESOLVED] Another Problem With Text Sentences

    Well, I encounter another problem while analysing text.

    I have a sentence like below:

    He said "What do you want from me ha?"
    The wife answer" I want your love and kids honey", the wife answered nicely.

    My question now:
    How to remove "What do you want from me ha?"
    " I want your love and kids honey"

    from the sentences.

    Please help, I just want to keep others only.

  2. #2
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: Another Problem With Text Sentences

    do you want to remove the words within quotes...
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Posts
    80

    Re: Another Problem With Text Sentences

    yes, i wanted so much. I know you have given answer in my previous, but it doesn't solve my problem.

  4. #4
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: Another Problem With Text Sentences

    i have given answer in your previous...sorry i dont remember...
    try this...
    VB Code:
    1. Dim sString1 As String
    2.     Dim sString2 As String
    3.     Dim iStartPos As Integer
    4.  
    5.     sString1 = "The wife answer " & Chr(34) & "I want your love and kids honey" & Chr(34) & ", the wife answered nicely."
    6.     iStartPos = InStr(sString1, Chr(34))
    7.     sString2 = Left(sString1, iStartPos - 1)
    8.     sString2 = sString2 & Mid(sString1, InStr(iStartPos + 1, sString1, Chr(34)) + 1)
    9.     MsgBox sString2
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  5. #5
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    266

    Re: Another Problem With Text Sentences

    msg1 = Mid(Text1.Text, 1, InStr(Text1.Text, Chr(34)) - 1)

    may b this would help u

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Posts
    80

    Re: Another Problem With Text Sentences

    Thank ganesh, it is only effective for the first line only. if any new sentences with are found, it is not working.

    noshaba, your answer is just like the answer given by ganesh. Is there any other way guys? Thanks a lot for your help

  7. #7
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,916

    Re: Another Problem With Text Sentences

    Write it as a function and call it whenever you need, eg
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4.  
    5.     Debug.Print StripQuotedText("He said " & Chr$(34) & "What do you want from me ha?" & Chr$(34))
    6.     Debug.Print StripQuotedText("The wife answer " & Chr$(34) & "I want your love and kids honey" & Chr$(34) & ", the wife answered nicely.")
    7.    
    8. End Sub
    9.  
    10. Public Function StripQuotedText(ByVal strText As String) As String
    11.    
    12.     Dim pos1 As Integer
    13.     Dim pos2 As Integer
    14.    
    15.     pos1 = InStr(strText, Chr$(34))
    16.     pos2 = InStrRev(strText, Chr$(34))
    17.    
    18.     StripQuotedText = Left$(strText, pos1 - 1)
    19.     StripQuotedText = StripQuotedText & Mid$(strText, pos2 + 1)
    20.    
    21. End Function
    Pete

    No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Posts
    80

    Re: Another Problem With Text Sentences

    Well, that is a good answer from pnish.
    But it is not the answer. Actually, the problem is like this:
    I read text file contains so many sentences with many quotes.
    Whatever strings inside the quotes are to be removed.
    Anything outside the quotes are to be saved.
    Imagine I have these inside the file

    Amanda says "Let us go to party tonight". But Ben said" We should go fishing honey"
    At the end they quarreled and said " Shut up". Bot of them ended up calmed down.

    A sentence could have many conversations in double quotes

  9. #9
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: Another Problem With Text Sentences

    you can change my code little bit by changing the startpos to the next quote position and then continue...
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  10. #10

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Posts
    80

    Re: Another Problem With Text Sentences

    Thanks Ganes
    sString2 = Left(sString1, iStartPos - 1)

    giving error when compiled

  11. #11
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: Another Problem With Text Sentences

    if string1 is null you will get error, could you post the error you are getting...
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  12. #12
    Addicted Member
    Join Date
    Feb 2006
    Location
    Hyderabad, India
    Posts
    233

    Re: Another Problem With Text Sentences

    Here is a function to remove quoted text.
    VB Code:
    1. Private Function removequoted(ByVal spinput As String)
    2. Dim bquotestart As Boolean
    3. Dim llen As Long
    4. Dim ll As Long
    5. Dim sres As String
    6. Dim schar As String
    7.  
    8. bquotestart = False
    9. llen = Len(spinput)
    10. For ll = 1 To llen
    11.   schar = Mid$(spinput, ll, 1)
    12.   If schar = Chr(34) Then bquotestart = Not bquotestart
    13.   If (bquotestart = False) Then
    14.     If (schar <> Chr(34)) Then
    15.       sres = sres & schar
    16.     Else
    17.       sres = sres & " "
    18.     End If
    19.   End If
    20.  
    21. Next ll
    22. removequoted = sres
    23. End Function
    I have checked it. Try it and see.

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Posts
    80

    Re: Another Problem With Text Sentences

    Great, this is working fine srisa. ganes, pnish, noshaha and srisa, You guys are great. Thanks a lot for these

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