thank you once again for your help.
--- Boyd Spangler <[EMAIL PROTECTED]> wrote:

> To parse the sample:
> Dim Pos as Integer, Result as String
> Pos=InStr(Text,":")
> Result=Left$(Text,Pos-1)
> -or in one step
> Result=Left$(text,InStr(Text,":")-1)
> Wayne
>
> Michael <[EMAIL PROTECTED]> wrote:
>
> how can i parse a string backwards ?
> i.e. Result = Mid$(sLines(nrLines), Pos + 2) takes
> all
> text from the "from left to right" postion +2 and
> puts
> in results. i need i.e. if the string is
> 111111:22222
> to take only 111111 and put it into Result.
>
> With some help from other people, I have coded this:
>
> Function Parse(text As String)
> Dim Pos As Integer
> Dim nrLines As Integer
> sLines = Split(txtMain.text, vbCrLf)
> Open App.Path & "\" & "output.txt" For Append As #1
> For nrLines = 0 To UBound(sLines)
> Pos = InStrRev(sLines(nrLines), text)
> Result = Mid$(sLines(nrLines), Pos + 2)
> Print #1, Result
> Next
> Close #1
> End Function
>
> Private Sub cmdParse_Click()
> Call Parse(":")
> End Sub
>
>
> Please help.
> --- Boyd Spangler <[EMAIL PROTECTED]> wrote:
>
> > I didn't see your request for multilanguage
> support
> > and I don't know much about it but check out this
> > site at VBHelper
> http://www.vb-helper.com/tut11.htm.
> > Wayne
> >
> > Michael <[EMAIL PROTECTED]> wrote:
> > Thank you very much for the great help! I have
> > updated
> > my code with your routine and it works (much
> > better).
> >
> > Please if you have any ideea answer to my email
> > about
> > Multilanguage Support in VB. If you did not
> receive
> > it, tell me to post it again.
> >
> >
> > --- Boyd Spangler <[EMAIL PROTECTED]> wrote:
> >
> > >
> > > A more effecient way to do this is:
> > >
> > > Private Sub cmdParse_Click()
> > >
> > > Dim Pos As Integer
> > >
> > > Dim nrLines as Integer (or Long)
> > >
> > > sLines=Split(txtMain.Text, vbCrLf)
> > >
> > > Open App.Path & "\" & "output.txt" For Append As
> > #1
> > >
> > > for nrLines = 0 to UBound(sLines)
> > >
> > > Pos=InStrRev(sLines(nrLines),"\")
> > >
> > > Result=Mid$(sLines(nrLines),Pos+1)
> > >
> > > Print #1,Result
> > >
> > > next
> > >
> > > Close #1
> > >
> > > End Sub
> > >
> > > Always define your variables. A variant is the
> > > slowest and largest of the variables.
> > >
> > > Split shouldn't be used over and over 3000 times
> > it
> > > too is slow. It is used right in the splitting
> of
> > > the main text anything else would be a waste of
> > > time.
> > >
> > > Also opening and closing a file 3000 times slows
> > > down the program. Open it, write information to
> it
> > > and then close it.
> > >
> > > Don't take anyting I say as insulting....it is
> not
> > > meant that way.
> > >
> > > Wayne
> > >
> > >
> > > anlaahoy <[EMAIL PROTECTED]> wrote:
> > >
> > > That's alright!
> > > I thought you were going to read the lines from
> a
> > > file...lol
> > >
> > > regards
> > >
> > > anla
> > > --- In [EMAIL PROTECTED], B Mihai
> > > <[EMAIL PROTECTED]>
> > > wrote:
> > > > Thank you all for your help.
> > > >
> > > > This is my solution resulting from your tips
> and
> > > > coding snippets.
> > > >
> > > > ===========
> > > > Private Sub cmdParse_Click()
> > > > Dim Temp, nrLines, LineNumber
> > > >
> > > > sLines = Split(txtMain.Text, vbCrLf)
> > > >
> > > > For nrLines = 0 To UBound(sLines)
> > > > LineNumber = sLines(nrLines)
> > > > ScanLine (LineNumber)
> > > > Next
> > > >
> > > > End Sub
> > > >
> > > > Function ScanLine(xLine)
> > > > Dim xTemp, Parsed, UParse, Result
> > > > xTemp = Split(xLine, "\")
> > > > UParse = UBound(xTemp)
> > > > Result = xTemp(UParse)
> > > > Open App.Path & "\" & "output.txt" For Append
> As
> > > #1
> > > > Print #1, Result
> > > > Close #1
> > > > End Function
> > > > ==============
> > > >
> > > > Very effective for what I needed.
> > > >
> > > > Happy coding and thank you all very much once
> > > again
> > > > for the ideeas!
> > > > --- anlaahoy <[EMAIL PROTECTED]> wrote:
> > > >
> > > > >
> > > > >
> > > > >
> > > > >     Dim sFileName As String
> > > > >     Dim lFile As Long
> > > > >     Dim sLine As String
> > > > >     Dim lCount As Long
> > > > >     Dim Temp
> > > > >     Dim Parsed
> > > > >
> > > > >  
> > > > >    
> > > > >     '  Change the filename below to your
> > > filename:
> > > > >     sFileName = "C:\test.txt"
> > > > >    
> > > > >     '  Get a safe file handle.
> > > > >     lFile = FreeFile
> > > > >     '  Initialize the menu index counter.
> > > > >     lCount = 0
> > > > >    
> > > > >     '  Open the input file.
> > > > >     Open sFileName For Input As #lFile
> > > > >    
> > > > >     '  Read every line in the file.
> > > > >          
> > > > >     Do While Not EOF(lFile)
> > > > >     lCount = lCount + 1
> > > > >         Line Input #lFile, sLine
> > > > >         If Not Len(sLine) = 0 Then
> > > > >        Temp = Split(sLine, "\")
> > > > >         For Parsed = 0 To UBound(Temp)
> > > > >             MsgBox Temp(Parsed),
> > vbInformation,
> > > > > "Split Sample"
>
=== message truncated ===



           
__________________________________
Do you Yahoo!?
Y! Messenger - Communicate in real time. Download now.
http://messenger.yahoo.com


To unsubscribe, send an email to:
[EMAIL PROTECTED]




Yahoo! Groups Sponsor
ADVERTISEMENT
click here
Web Bug from http://us.adserver.yahoo.com/l?M=295196.4901138.6071305.3001176/D=groups/S=:HM/A=2128215/rand=193863187


Yahoo! Groups Links

Reply via email to