troubleshooting Question

rtf

Avatar of punjabijatt
punjabijatt asked on
Visual Basic Classic
11 Comments1 Solution335 ViewsLast Modified:
I need to make a program in vb that would test rtf(rich text files).  What i mean by test is this. So the program scans through the rtf file and whenever the program hits   " ESN:  (space)" it records what ever is after that until it hits another (space)


So suppose the files has the follwoing line.


ESN : john anderson

So it will record only the word john.


But instead of words it will be ESN : 123456789


it will be numbers.

this is what is have so far i get the user to select the rtf file but how do i load it.
and how do i do the actual scanning. Take a look at the code that i have so far.


Private Sub Command1_Click()
CommonDialog1.Filter = "Rich Text Format|*.rtf"
CommonDialog1.ShowOpen
FileName = CommonDialog1.FileName
Call CountSpaces

End Sub

Private Sub Command2_Click()
End
End Sub

Function CountSpaces()

Dim strText As String, lngSpace1 As Long, lngSpace2 As Long, strInBetween As String

strText = rtfRichTextBox.Text

InStr(1, strText, "ESN: ") = lngSpace1

'Check to see if the ESN exists. if it doesnt, then quit
If lngSpace1 < 1 Then Exit Function

lngSpace2 = InStr(lngSpace1 + 1, strText, " ")

'Check to see if the second space exists. if it doesnt, then quit
If lngSpace2 < 1 Then Exit Function
 

strInBetween = Mid(strText, lngSpace1, lngSpace2 - lngSpace1)

MsgBox "The spaced out message is: " & strInBetween & "."

End Function



thanks


I don't think it is right

but that's why i am here right!

thanks guys
i would appreciate your help.

ASKER CERTIFIED SOLUTION
spauljoseph

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 11 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros