Question Search Between Words Or After A Word in string

moegreen

New member
Joined
May 12, 2009
Messages
1
Programming Experience
Beginner
Hi Guys, I'm a complete coding newbie, but I'm trying to make a program that displays how many people are in a telephone queue by reading from a log file. and having a timer update the number every 3rd second.

The problem is, that the lines in the logfile are very variaible so I need to find a way to search the entire string(I'm reading the entire log file and reversing to search from the bOttom up."

CODE:

VB.NET:
Public Class Form1


    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        'Do

        Dim fileReader As String
        fileReader = My.Computer.FileSystem.ReadAllText("x:\A.log")
        fileReader = (StrReverse(fileReader))
        Dim strMidString1 As String
        Dim strMidString2 As String

        'MsgBox(fileReader)
        strMidString1 = Mid((fileReader), 161, 1)
        strMidString2 = Mid((fileReader), 162, 1)

        'MsgBox(strMidString)

        RichTextBox1.Text = (strMidString1)
        RichTextBox2.Text = (strMidString2)

    End Sub

As you can see, i read the string backwards and go X number of characters to find the number(s). The problem is that i can't really do.

So can i search the entire log backwards, look between "are " and "calls". and get that printed out. or simply go backwards in the log to find "calls(sllac)" and print out the the two characters after that some how?

I've rememeber i've done the first thing in c# before.

this is how the log file looks like:

05/12/07 10:17:42.015 Snapshot response -> There are 2 calls at this device
05/12/07 10:17:42.015 Snapshot response -> CallID = 17
05/12/07 10:17:42.015 Snapshot response -> CallID = 18
05/12/07 10:17:42.015 InvokeID=79. CSTACONFIRMATION : CSTA_SNAPSHOT_DEVICE_CONF
05/12/07 10:17:46.140 cstaSnapshotDeviceReq DevId=460, InvokeID=80
05/12/07 10:17:46.390 Snapshot response -> There are 1 calls at this device
05/12/07 10:17:46.390 Snapshot response -> CallID = 18
05/12/07 10:17:46.390 InvokeID=80. CSTACONFIRMATION : CSTA_SNAPSHOT_DEVICE_CONF
05/12/07 10:17:50.468 cstaSnapshotDeviceReq DevId=460, InvokeID=81
05/12/07 10:17:50.656 Snapshot response -> There are 1 calls at this device
05/12/07 10:17:50.656 Snapshot response -> CallID = 18
05/12/07 10:17:50.656 InvokeID=81. CSTACONFIRMATION : CSTA_SNAPSHOT_DEVICE_CONF


Notice when theres 1 call there's one line. like:

05/12/07 10:17:50.656 Snapshot response -> There are 1 calls at this device
05/12/07 10:17:50.656 Snapshot response -> CallID = 18

But if there's two calls. there's two lines.
05/12/07 10:17:42.015 Snapshot response -> There are 2 calls at this device
05/12/07 10:17:42.015 Snapshot response -> CallID = 17
05/12/07 10:17:42.015 Snapshot response -> CallID = 18

And there's none... Well, there's no lines after.

Thanks

Jesper Petterson
 
Back
Top