?
Solved

VB.NET Save/Load/Filter text

Posted on 2010-01-11
63
Medium Priority
?
466 Views
Last Modified: 2013-11-26
Hi, I have filter which filters textbox1.text and shows filtered text.

I need: To filter already filtered text and do some action, read above:

Example of already filtered text in the textbox:

[09:04:30] [System Message] <Player1>[Ping:31]  has joined your game!.
[09:04:46] [System Message] <Player1>  has left your game!(4).
[09:04:55] [System Message] <Player2>[Ping:42]  has joined your game!.
[09:04:59] [System Message] <Player2>  has left your game!(4).

and so on...

What i need from that text is..
When player joins, i need to record his name and number like
Imbaplayer has joined - Number 1
Imbaplayer2 has joined - Number 2
Imbaplayer 3 has joined - number 3

But if some of them leaves like

Imbaplayer2 has left, then imbaplayer 3 is becoming player 2 not 3... how can i do that with datagridview or something...
0
Comment
Question by:_ColdFire_
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 37
  • 26
63 Comments
 

Author Comment

by:_ColdFire_
ID: 26282636
I would like that info to appear in datagridview1 with columns : Player's name : name and Number : number

(Maximum 9 players)


form.png
0
 
LVL 9

Expert Comment

by:magicdlf
ID: 26282971
List view version. Actually I don't understand why you need the player number.

Private players As New List(Of String)()
Private Sub loadText(ByVal str As String)
    Dim lines As String() = str.Split(New Char() {ControlChars.Lf})
    For Each line As String In lines
        If line.Contains("[System Message]") Then
            If line.Contains("join") Then
                Dim pos1 As Integer = line.IndexOf("]"c, 12) + 1
                Dim pos2 As Integer = line.LastIndexOf("[")
                Dim playername As String = line.Substring(pos1, pos2 - pos1).Trim()
                listBox1.Items.Add(playername)
            End If
            If line.Contains("left") Then
                Dim pos1 As Integer = line.IndexOf("]"c, 12) + 1
                Dim pos2 As Integer = line.LastIndexOf("has")
                Dim playername As String = line.Substring(pos1, pos2 - pos1).Trim()
                listBox1.Items.Remove(playername)
            End If
        End If
    Next
End Sub

Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
    loadText(textBox1.Text)
End Sub
0
 
LVL 9

Expert Comment

by:magicdlf
ID: 26283029
Public Partial Class Form1
    Inherits Form
    Public Sub New()
        InitializeComponent()
    End Sub
   
    Private players As New List(Of String)()
    Private Sub loadText(ByVal str As String)
        Dim lines As String() = str.Split(New Char() {ControlChars.Lf})
        For Each line As String In lines
            If line.Contains("[System Message]") Then
                If line.Contains("join") Then
                    Dim pos1 As Integer = line.IndexOf("]"c, 12) + 1
                    Dim pos2 As Integer = line.LastIndexOf("["c)
                    Dim playername As String = line.Substring(pos1, pos2 - pos1).Trim()
                    players.Add(playername)
                End If
                If line.Contains("left") Then
                    Dim pos1 As Integer = line.IndexOf("]"c, 12) + 1
                    Dim pos2 As Integer = line.LastIndexOf("has")
                    Dim playername As String = line.Substring(pos1, pos2 - pos1).Trim()
                    players.Remove(playername)
                End If
            End If
        Next
        dataGridView1.Rows.Clear()
        Dim num As Integer = 1
        For Each player As String In players
            dataGridView1.Rows.Add(New Object() {player, System.Math.Max(System.Threading.Interlocked.Increment(num),num - 1)})
        Next
    End Sub
   
    Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
        loadText(textBox1.Text)
    End Sub
End Class

0
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 

Author Comment

by:_ColdFire_
ID: 26283312
Also, how to make some cache or something, so these text messages are remembered , because if textbox of application is cleared then no all results will be cleared i think.
0
 
LVL 9

Expert Comment

by:magicdlf
ID: 26283325
Store to file?
0
 

Author Comment

by:_ColdFire_
ID: 26283377
sure.. why not. but file is also cleared when textbox is empty.
0
 
LVL 9

Expert Comment

by:magicdlf
ID: 26283400
Wait a minute, you want to store the log file, right?
0
 

Author Comment

by:_ColdFire_
ID: 26283416
how to save information to file, and add only new line and do not delete old ones?
0
 
LVL 9

Expert Comment

by:magicdlf
ID: 26283451
Some thing like this:
Using fs As New FileStream("log.txt", FileMode.OpenOrCreate)
    Dim sw As New StreamWriter()
    sw.WriteLine(textBox1.Text)
End Using

What do you mean by not delete old ones? in the textbox1?
0
 

Author Comment

by:_ColdFire_
ID: 26283575
It write lines from textbox to file, but as soon as textbox is empty, the log file becomes empty as well.
0
 

Author Comment

by:_ColdFire_
ID: 26283602

    Private players As New List(Of String)()
    Private Sub loadText2(ByVal str As String)
        Dim lines As String() = str.Split(New Char() {ControlChars.Lf})
        For Each line As String In lines
            If line.Contains("[System Message]") Then
                If line.Contains("join") Then
                    Dim pos1 As Integer = line.IndexOf("]"c, 12) + 1
                    Dim pos2 As Integer = line.LastIndexOf("["c)
                    Dim playername As String = line.Substring(pos1, pos2 - pos1).Trim()
                    players.Add(playername)
                End If
                If line.Contains("left") Then
                    Dim pos1 As Integer = line.IndexOf("]"c, 12) + 1
                    Dim pos2 As Integer = line.LastIndexOf("has")
                    Dim playername As String = line.Substring(pos1, pos2 - pos1).Trim()
                    players.Remove(playername)
                End If
            End If
        Next
        DataGridView1.Rows.Clear()
        If TextBox1.Text = "" Then
            DataGridView1.Rows.Clear()
        Else
            Dim num As Integer = 1
            For Each player As String In players
                DataGridView1.Rows.Add(New Object() {player, System.Math.Max(System.Threading.Interlocked.Increment(num), num - 1)})
            Next
        End If
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim ps() As Process = Process.GetProcessesByName("garena")
        If ps.Length > 0 Then
            Dim enumerator As New WindowsEnumerator
            For Each child As ApiWindow In enumerator.GetChildWindows(ps(0).MainWindowHandle)
                If child.ClassName.ToLower = "richedit20w" Then
                    Dim txt As String = child.MainWindowTitle
                    TextBox1.Text = txt
                    Exit For
                End If
            Next
        End If
        loadText(TextBox1.Text)

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
    Private Sub loadText(ByVal str As String)
        Dim lines As String() = str.Split(New Char() {ControlChars.Lf})
        Dim sb As New StringBuilder()
        For Each line As String In lines
            If line.Contains("[System Message]") AndAlso ((line.Contains("join") OrElse line.Contains("left"))) Then
                sb.AppendLine(line)
            End If
        Next
        TextBox1.Text = sb.ToString()
    End Sub

    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        loadText2(TextBox1.Text)
    End Sub
End Class

Open in new window

0
 
LVL 9

Expert Comment

by:magicdlf
ID: 26283606
I don't think so. It depends on how you open the file. Please try this FileMode.Append instead of the FileMode.OpenOrCreate
0
 

Author Comment

by:_ColdFire_
ID: 26283631
Also, when it adds players to datagridview, it just keeps adding and adding without stop, even when there are no players joined ..
0
 

Author Comment

by:_ColdFire_
ID: 26283636
read the code, maybe you will find a fault
0
 
LVL 9

Expert Comment

by:magicdlf
ID: 26283656
Remember to clear the text in the timer.
    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        loadText2(TextBox1.Text)
        TextBox1.Text = ""
    End Sub
0
 

Author Comment

by:_ColdFire_
ID: 26283727
why it just keeps adding values to datagridview even when no players joined or even when textbox is emtpy
0
 

Author Comment

by:_ColdFire_
ID: 26283734
Playername field is empty and values are just keep growing....
0
 
LVL 9

Expert Comment

by:magicdlf
ID: 26283793
move this line into the loadText2 method:
Private players As New List(Of String)()
remove the "Private"
0
 

Author Comment

by:_ColdFire_
ID: 26283931
why player numbers starts with number 2?
0
 
LVL 9

Expert Comment

by:magicdlf
ID: 26283964
This line is not correct.
dataGridView1.Rows.Add(New Object() {player, System.Math.Max(System.Threading.Interlocked.Increment(num),num - 1)})
change to:
dataGridView1.Rows.Add(New Object() {player, num} )
num = num + 1
0
 

Author Comment

by:_ColdFire_
ID: 26284044
where shall i put this code ?

Using fs As New FileStream("log.txt", FileMode.OpenOrCreate)
    Dim sw As New StreamWriter()
    sw.WriteLine(textBox1.Text)
End Using

and also, how to use it to get data to datagridview
0
 
LVL 9

Expert Comment

by:magicdlf
ID: 26284130
1. put this to timer1
2. you dont need to get data from datagridview, you just need to read it from players
0
 

Author Comment

by:_ColdFire_
ID: 26284204
The thing is, that players are joining and leaving everything is fine, everything works but, as soon as i clear textbox (chat) on the main app, from which all data being gathered, datagrid becomes empty. How to fix that?
0
 
LVL 9

Expert Comment

by:magicdlf
ID: 26284240
Remove timer2
In timer1, after this line
   TextBox1.Text = txt
put
   loadText2(txt)
0
 

Author Comment

by:_ColdFire_
ID: 26284349
Using fs As New FileStream("log.txt", FileMode.OpenOrCreate)
    Dim sw As New StreamWriter()
    sw.WriteLine(textBox1.Text)
End Using


Error::

Error      1      Overload resolution failed because no accessible 'New' accepts this number of arguments.

Dim sw As New StreamWriter()
0
 
LVL 9

Expert Comment

by:magicdlf
ID: 26284392
typo...
 Dim sw As New StreamWriter(fs)
0
 

Author Comment

by:_ColdFire_
ID: 26284497
text will be saved, but shouldnt it be readed from that text file?
0
 
LVL 9

Expert Comment

by:magicdlf
ID: 26284512
Sorry? I didn't get it.
0
 

Author Comment

by:_ColdFire_
ID: 26284581
Right, text what what I'm filtering and so on, I'm reading from another applications textbox, the thing is, that when that chatbox (textbox1) is cleated, all data is lost, as my application is filtering data from that texbox. So, I need to make a copy of chat what is on another application and then, read that log so when the chat is cleared , nothing happens to my application as text file will be still holding all the data.
0
 
LVL 9

Expert Comment

by:magicdlf
ID: 26284608
I get it. You don't need to use a file at this moment. Follow my instructions in 26284240 and I believe you already have the feature that you requested.
0
 
LVL 9

Accepted Solution

by:
magicdlf earned 2000 total points
ID: 26284660
I am going to take some sleep. Hope you good luck~ Post another question if this is not clear for you. A tip: change the zone to "VB.NET, C# and C#.net" that will attract more expert to help. Good luck!
0
 

Author Comment

by:_ColdFire_
ID: 26284863
I followed your comment, and did like you said, but still when textbox is cleared , all values from datagridview becomes cleared.
0
 
LVL 9

Expert Comment

by:magicdlf
ID: 26289982
Hello, can you please attach your code again?
0
 

Author Comment

by:_ColdFire_
ID: 26291345
Sure...
Imports System.Collections.Generic
Imports System.Runtime.InteropServices
Imports System.Text
Imports System.IO
Imports System.IO.StreamWriter
Public Class frmdh
    Private Sub loadText2(ByVal str As String)
        Dim players As New List(Of String)()
        Dim lines As String() = str.Split(New Char() {ControlChars.Lf})
        For Each line As String In lines
            If line.Contains("[System Message]") Then
                If line.Contains("join") Then
                    Dim pos1 As Integer = line.IndexOf("]"c, 12) + 1
                    Dim pos2 As Integer = line.LastIndexOf("["c)
                    Dim playername As String = line.Substring(pos1, pos2 - pos1).Trim()
                    players.Add(playername)
                End If
                If line.Contains("left") Then
                    Dim pos1 As Integer = line.IndexOf("]"c, 12) + 1
                    Dim pos2 As Integer = line.LastIndexOf("has")
                    Dim playername As String = line.Substring(pos1, pos2 - pos1).Trim()
                    players.Remove(playername)
                End If
            End If
        Next
        DataGridView1.Rows.Clear()
        Dim num As Integer = 1
        For Each player As String In players
            DataGridView1.Rows.Add(New Object() {player, num})
            num = num + 1
        Next
    End Sub
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim ps() As Process = Process.GetProcessesByName("process")
        If ps.Length > 0 Then
            Dim enumerator As New WindowsEnumerator
            For Each child As ApiWindow In enumerator.GetChildWindows(ps(0).MainWindowHandle)
                If child.ClassName.ToLower = "richedit20w" Then
                    Dim txt As String = child.MainWindowTitle
                    TextBox1.Text = txt
                    Exit For
                End If
            Next
        End If
        loadText(TextBox1.Text)
        loadText2(TextBox1.Text)
    End Sub
    Private Sub loadText(ByVal str As String)
        Dim lines As String() = str.Split(New Char() {ControlChars.Lf})
        Dim sb As New StringBuilder()
        For Each line As String In lines
            If line.Contains("[System Message]") AndAlso ((line.Contains("join") OrElse line.Contains("left"))) Then
                sb.AppendLine(line)
            End If
        Next
        TextBox1.Text = sb.ToString()
    End Sub

    Private Sub RealTimeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RealTimeToolStripMenuItem.Click
        Timer1.Interval = 1
    End Sub

    Private Sub OncePerSecondToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OncePerSecondToolStripMenuItem.Click
        Timer1.Interval = 1000
    End Sub

    Private Sub OnceInFiveSecondsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OnceInFiveSecondsToolStripMenuItem.Click
        Timer1.Interval = 5000
    End Sub

    Private Sub OnceInTenSecondsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OnceInTenSecondsToolStripMenuItem.Click
        Timer1.Interval = 10000
    End Sub

    Private Sub OnceInThirtySecondsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OnceInThirtySecondsToolStripMenuItem.Click
        Timer1.Interval = 30000
    End Sub

    Private Sub OnceInSixtySecondsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OnceInSixtySecondsToolStripMenuItem.Click
        Timer1.Interval = 60000
    End Sub

    Private Sub Every300secToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Every300secToolStripMenuItem.Click
        Timer1.Interval = 300000
    End Sub

    Private Sub RefreshNowToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RefreshNowToolStripMenuItem.Click
        Dim ps() As Process = Process.GetProcessesByName("process")
        If ps.Length > 0 Then
            Dim enumerator As New WindowsEnumerator
            For Each child As ApiWindow In enumerator.GetChildWindows(ps(0).MainWindowHandle)
                If child.ClassName.ToLower = "richedit20w" Then
                    Dim txt As String = child.MainWindowTitle
                    TextBox1.Text = txt
                    Exit For
                End If
            Next
        End If
        loadText(TextBox1.Text)
        loadText2(TextBox1.Text)
    End Sub
    Private Sub StartToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StartToolStripMenuItem.Click
        If Timer1.Enabled = True Then
            Form1.NotifyIcon1.BalloonTipText = "Drophack is already running."
            Form1.NotifyIcon1.ShowBalloonTip(5000)
        Else
            Timer1.Enabled = True
            Timer1.Start()
        End If
    End Sub
    Private Sub StopToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StopToolStripMenuItem.Click
        If Timer1.Enabled = False Then
            Form1.NotifyIcon1.BalloonTipText = "Drophack is already stopped."
            Form1.NotifyIcon1.ShowBalloonTip(5000)
        Else
            Timer1.Enabled = False
            Timer1.Stop()
        End If
    End Sub

Open in new window

0
 
LVL 9

Expert Comment

by:magicdlf
ID: 26291353

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim ps() As Process = Process.GetProcessesByName("process")
        If ps.Length > 0 Then
            Dim enumerator As New WindowsEnumerator
            For Each child As ApiWindow In enumerator.GetChildWindows(ps(0).MainWindowHandle)
                If child.ClassName.ToLower = "richedit20w" Then
                    Dim txt As String = child.MainWindowTitle
                    TextBox1.Text = txt
                    loadText2(txt )
                    Exit For
                End If
            Next
        End If
    End Sub
0
 

Author Comment

by:_ColdFire_
ID: 26291568
and where should i put loadtext(textbox1.text) ?
0
 

Author Comment

by:_ColdFire_
ID: 26291569

    Private Sub loadText(ByVal str As String)
        Dim lines As String() = str.Split(New Char() {ControlChars.Lf})
        Dim sb As New StringBuilder()
        For Each line As String In lines
            If line.Contains("[System Message]") AndAlso ((line.Contains("join") OrElse line.Contains("left"))) Then
                sb.AppendLine(line)
            End If
        Next
        TextBox1.Text = sb.ToString()
    End Sub

Open in new window

0
 
LVL 9

Expert Comment

by:magicdlf
ID: 26291783
you don't. Just try my solution and let me know the result.
0
 

Author Comment

by:_ColdFire_
ID: 26291823
k
0
 

Author Comment

by:_ColdFire_
ID: 26291875
Nothing is in the textbox at all. it remains empty...

Loadtext(Textbox1.Text) - Filters all chat messages and leaves just sytem (join / Leave) messages.
Loadtext2(Textbox1.Text) - Filters those join and leave messages and insert into datagridview
0
 

Author Comment

by:_ColdFire_
ID: 26291890
Ok. it does work , as before, but as soon as i clear textbox, datagridview becomes empty.
0
 
LVL 9

Expert Comment

by:magicdlf
ID: 26291900
Can you post the code again?  make sure you dont have any Loadtext(Textbox1.Text) and  Loadtext2(Textbox1.Text) in your code and the only one you have is Loadtext2(txt)
0
 

Author Comment

by:_ColdFire_
ID: 26291944

Imports System.Collections.Generic
Imports System.Runtime.InteropServices
Imports System.Text
Imports System.IO
Imports System.IO.StreamWriter
Public Class frmdh
    Private Sub loadText2(ByVal str As String)
        Dim players As New List(Of String)()
        Dim lines As String() = str.Split(New Char() {ControlChars.Lf})
        For Each line As String In lines
            If line.Contains("[System Message]") Then
                If line.Contains("join") Then
                    Dim pos1 As Integer = line.IndexOf("]"c, 12) + 1
                    Dim pos2 As Integer = line.LastIndexOf("["c)
                    Dim playername As String = line.Substring(pos1, pos2 - pos1).Trim()
                    players.Add(playername)
                End If
                If line.Contains("left") Then
                    Dim pos1 As Integer = line.IndexOf("]"c, 12) + 1
                    Dim pos2 As Integer = line.LastIndexOf("has")
                    Dim playername As String = line.Substring(pos1, pos2 - pos1).Trim()
                    players.Remove(playername)
                End If
            End If
        Next
        DataGridView1.Rows.Clear()
        Dim num As Integer = 1
        For Each player As String In players
            DataGridView1.Rows.Add(New Object() {player, num})
            num = num + 1
        Next
    End Sub
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim ps() As Process = Process.GetProcessesByName("process")
        If ps.Length > 0 Then
            Dim enumerator As New WindowsEnumerator
            For Each child As ApiWindow In enumerator.GetChildWindows(ps(0).MainWindowHandle)
                If child.ClassName.ToLower = "richedit20w" Then
                    Dim txt As String = child.MainWindowTitle
                    TextBox1.Text = txt
                    loadText2(txt)
                    Exit For
                End If
            Next
        End If
    End Sub

    Private Sub RealTimeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RealTimeToolStripMenuItem.Click
        Timer1.Interval = 1
    End Sub

    Private Sub OncePerSecondToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OncePerSecondToolStripMenuItem.Click
        Timer1.Interval = 1000
    End Sub

    Private Sub OnceInFiveSecondsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OnceInFiveSecondsToolStripMenuItem.Click
        Timer1.Interval = 5000
    End Sub

    Private Sub OnceInTenSecondsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OnceInTenSecondsToolStripMenuItem.Click
        Timer1.Interval = 10000
    End Sub

    Private Sub OnceInThirtySecondsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OnceInThirtySecondsToolStripMenuItem.Click
        Timer1.Interval = 30000
    End Sub

    Private Sub OnceInSixtySecondsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OnceInSixtySecondsToolStripMenuItem.Click
        Timer1.Interval = 60000
    End Sub

    Private Sub Every300secToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Every300secToolStripMenuItem.Click
        Timer1.Interval = 300000
    End Sub

    Private Sub RefreshNowToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RefreshNowToolStripMenuItem.Click
        Dim ps() As Process = Process.GetProcessesByName("process")
        If ps.Length > 0 Then
            Dim enumerator As New WindowsEnumerator
            For Each child As ApiWindow In enumerator.GetChildWindows(ps(0).MainWindowHandle)
                If child.ClassName.ToLower = "richedit20w" Then
                    Dim txt As String = child.MainWindowTitle
                    TextBox1.Text = txt
                    loadText2(txt)
                    Exit For
                End If
            Next
        End If
    End Sub
    Private Sub StartToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StartToolStripMenuItem.Click
        Timer1.Enabled = True
        Timer1.Start()
    End Sub
    Private Sub StopToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StopToolStripMenuItem.Click
        Timer1.Enabled = False
        Timer1.Stop()
    End Sub
    Private Sub ListOfCurrentConnectionsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListOfCurrentConnectionsToolStripMenuItem.Click
        'nothing
    End Sub
End Class

Open in new window

0
 

Author Comment

by:_ColdFire_
ID: 26291951
i deleted loadtext at all, just loadtext2 left. and still same.
0
 
LVL 9

Expert Comment

by:magicdlf
ID: 26292159
Sorry I messed up too.... You need to specify the process name otherwise the code (loadText) will never be executed.
0
 

Author Comment

by:_ColdFire_
ID: 26292189
didn't get that.
0
 
LVL 9

Expert Comment

by:magicdlf
ID: 26292198
Dim ps() As Process = Process.GetProcessesByName("process")
        If ps.Length > 0 Then
This one. Please debug and observe the ps and I bet your ps.Length is 0 in this case.
0
 

Author Comment

by:_ColdFire_
ID: 26292202
It shows values in datagridview correctly, when someone leaves and joins and so on, but when textbox is cleared (TEXTBOX OF PROCESS FROM WHICH DATA IS GATHERED) then datagridview becomes empty.
0
 
LVL 9

Expert Comment

by:magicdlf
ID: 26292224
huh.....   I think I misunderstood your requirement. Could you please give me a sample about your another process?
0
 

Author Comment

by:_ColdFire_
ID: 26292281
another process is garena.exe

You can download it from garena.com. Then enter any room and here you go, you will have a chat window from which all data is gathered for my app. But the thing is, that if you want to see those messages like : somebody joined or left your game, you will need warcraft 3 which i think you don't have...

But still you can see how those messages are displayed and check them...
0
 

Author Comment

by:_ColdFire_
ID: 26292284
Debug showed that
            ps.Length      1      Integer
So it's 1 not 0
0
 

Author Comment

by:_ColdFire_
ID: 26292330
I will give you screenshots better.
0
 

Author Comment

by:_ColdFire_
ID: 26292357
Image.. :P
Untitled.jpg
0
 

Author Comment

by:_ColdFire_
ID: 26292380
I think it's probably because the chat itself is being sorted by timer, and all those messages are sorted and then inserted in datagridview, but as soon as chat window is blank, then there is nothing to filter anymore and datagridview becomes blank. That's why i told you that i need to save a copy of those messages and read them from there (like from text file or something) so if chat window is cleared, then all messages will still be saved in the text file and data will not be lost.
0
 
LVL 9

Expert Comment

by:magicdlf
ID: 26292672
Did you mean you clear the garena chat window?  I didn't expect that. I was thinking it is kind of war3 server that always running.  So you will need to change your code a little to do that. Just take some time and enjoy the coding. This would be a very challenge problem for you to improve you skills.
0
 

Author Comment

by:_ColdFire_
ID: 26292703
lol :DDDD
0
 

Author Comment

by:_ColdFire_
ID: 26292713
You might want to have a look on this ;) (Link above)
0
 
LVL 9

Expert Comment

by:magicdlf
ID: 26292717
Btw, if you use a timer to draw data from the chat window, the data will repeat again and again. You need to detect the "clear" event for the chat window and then save to the file.
0
 

Author Comment

by:_ColdFire_
ID: 26292831
how can I detect event?
0
 
LVL 9

Expert Comment

by:magicdlf
ID: 26292855
You dont. You just need to compare the text in chat with the last time (you need to keep a copy of previous chat text in the timer). If the new text's length is short than the old one, you know ; )
0
 

Author Comment

by:_ColdFire_
ID: 26296821
Maybe it's possible to make like .. If textbox of garena is empty, then it stops reading everything and waiting while join/leave message appears again?
0
 
LVL 9

Expert Comment

by:magicdlf
ID: 26300414
hmmmm, correct. You can have a try. : )
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question