[TUT] Process List

Posts 1–12 of 12 · Page 1 of 1
[TUT] Process List
here i show u how to make a process list like this



1. add a listbox to your form
2. double click on the form and insert this code

Code:
 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim p As Process
        For Each p In System.Diagnostics.Process.GetProcesses
            ListBox1.Items.Add(p.ProcessName)
        Next
    End Sub

how to end a proess

1. add a button
2. add a textbox
3. double click on the button and paste this code


Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        On Error Resume Next
        Name = TextBox1.text                'just write notepad or anything without .exe
        For Each ProgrammName In Process.GetProcessesByName(Name)
            ProgrammName.Kill()
        Next
    End Sub
hop you enjoyed
Quote Originally Posted by Kudi View Post
here i show u how to make a process list like this



1. add a listbox to your form
2. double click on the form and insert this code

Code:
 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim p As Process
        For Each p In System.Diagnostics.Process.GetProcesses
            ListBox1.Items.Add(p.ProcessName)
        Next
    End Sub

how to end a proess

1. add a button
2. add a textbox
3. double click on the button and paste this code


Code:
]Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        On Error Resume Next
        Name = TextBox1.text                'just write notepad or anything without .exe
        For Each ProgrammName In Process.GetProcessesByName(Name)
            ProgrammName.Kill()
        Next
    End Sub
hop you enjoyed
nice, but remove the ] from Private Sub button1_click...

2.Wrong section..
Code:
 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim p As Process
        For Each p In System.Diagnostics.Process.GetProcesses
            ListBox1.Items.Add(p.ProcessName)
        Next
    End Sub
In-Needed!
Quote Originally Posted by user590177 View Post
In-Needed!
What do you mean?
Quote Originally Posted by Skinnlaw View Post
What do you mean?
no one knows
He explicitly declared the p As a "Process" prior to the loop, which is indeed more correct than saying

[highlight=vb.net]
For each p in Process.GetProcesses
[/highlight]

Which only implicitly declares p As process which is a "less favored" programming habit.

Oh yeah, never EVER use On Error Resume Next, it's ungainly.
Quote Originally Posted by Jason View Post
He explicitly declared the p As a "Process" prior to the loop, which is indeed more correct than saying

[highlight=vb.net]
For each p in Process.GetProcesses
[/highlight]

Which only implicitly declares p As process which is a "less favored" programming habit.

Oh yeah, never EVER use On Error Resume Next, it's ungainly.
In 3 guys, only 1 () can understand me
Quote Originally Posted by user590177 View Post
In 3 guys, only 1 () can understand me
I did say you were wrong though lol.

Also, it's "unneeded" not "in-needed"
Quote Originally Posted by Jason View Post


I did say you were wrong though lol.

Also, it's "unneeded" not "in-needed"

NOOOOOOOO! Now the other guys will think that I'm dumb :'(
Well in-needed, unneeded, wtf? We aren't in my class while we're learning english.... (Thx to god we aren't). I think that peeps can understand what i said...and...Why me wrong?
Quote Originally Posted by user590177 View Post

NOOOOOOOO! Now the other guys will think that I'm dumb :'(
Well in-needed, unneeded, wtf? We aren't in my class while we're learning english.... (Thx to god we aren't). I think that peeps can understand what i said...and...Why me wrong?
You said that he had no need to explicitly declare "p" as a process before using it in the loop like this:

[highlight=vb.net]
For each p in Process.GetProcesses
[/highlight]

Which would mean p was only implicitly declared as a process, it's always better to make any and all declarations explicit as it allows you to keep track of types, and ensures you don't get any invalid type conversions at runtime.

Either of the following are valid and explicit declarations for a For-Each loop:

[highlight=vb.net]
'Option number one:
Dim p As Process
For each p in Process.GetProcesses
'lalala
Next p

Option number two:
For each p As Process in Process.GetProcesses
'lalala
Next
[/highlight]

If you turn on Option Strict, it will disallow implicit declarations.
Quote Originally Posted by Jason View Post


You said that he had no need to explicitly declare "p" as a process before using it in the loop like this:

[highlight=vb.net]
For each p in Process.GetProcesses
[/highlight]

Which would mean p was only implicitly declared as a process, it's always better to make any and all declarations explicit as it allows you to keep track of types, and ensures you don't get any invalid type conversions at runtime.

Either of the following are valid and explicit declarations for a For-Each loop:

[highlight=vb.net]
'Option number one:
Dim p As Process
For each p in Process.GetProcesses
'lalala
Next p

Option number two:
For each p As Process in Process.GetProcesses
'lalala
Next
[/highlight]

If you turn on Option Strict, it will disallow implicit declarations.
yea.?
Quote Originally Posted by user590177 View Post
yea.?
Spam less please.
Posts 1–12 of 12 · Page 1 of 1
This thread is closed for replies.

Tags for this Thread

None

Talk with us