VB2010 Help Plz!

Posts 1–7 of 7 · Page 1 of 1
VB2010 Help Plz!
Okay, I have a label and I want the status of a specific process.

Example, if "notepad.exe" is running, it would says (label1text) Notepad is running.

How?

Also, with the command shell, I want to do that Shell("netsh interface ip set address "Connexion au R‚seau local" source=dhcp") but as you can see, in the command line, there are other "", so it fuck up. Is there any other way like running the command by adding the .bat to resources or else?

Please help!

Also, how to you find the IP with vb2010?
If you wanna use quotes in a string use " & Chr34& " in place of the quote.

This:
Code:
 Shell("netsh interface ip set address "Connexion au R‚seau local" source=dhcp")
Would turn into
Code:
 Shell("netsh interface ip set address " & Chr34& "Connexion au R‚seau local" & Chr34& " source=dhcp")

Also, here's a function I found on DIC that checks if a process is running:
Code:
Public Function ProcessIsRunning(name As String) As Boolean
	'here we're going to get a list of all running processes on
	'the computer
	For Each clsProcess As Process In Process.GetProcesses()
		If clsProcess.ProcessName.StartsWith(name) Then
			'process found so it's running so return true
			Return True
		End If
	Next
	'process not found, return false
	Return False
End Function
Copy and paste that into your code and use it like this:

Code:
If ProcessIsRunning("notepad") = True then
Label1.text = "notepad is running"
Else
Label1.text = "notepad is not running"
End If
Whoops, I forgot a space.

Here, should work:
Shell("netsh interface ip set address " & Chr34 & "Connexion au R‚seau local" & Chr34 & " source=dhcp")
Quote Originally Posted by Lolland View Post
Whoops, I forgot a space.

Here, should work:
Shell("netsh interface ip set address " & Chr34 & "Connexion au R‚seau local" & Chr34 & " source=dhcp")
Yeah usig Chr34 is overkill, just use a double quote /fp

This is a "sentence"...lol

In IDE:

"This is a ""sentence""...lol"

Not hard.

Also, that process check method is pretty poor, the Process class already has a "GetProcessesByName" function, so why loop through all the processes and only check that the process name starts with the desired name? If I'm searching for a process named something like "We" it will match any process that starts with "we".

[php]
Private Function IsProcessOpen(ByVal ProcName As String) As Boolean
If Process.GetProcessesByName(ProcName).Length > 0 Then Return True
End Function
[/php]

That's all you need essentially.
You can just use double quotes...
Wow thanks guys! I'll try that when I get home ^^
Posts 1–7 of 7 · Page 1 of 1
This thread is closed for replies.

Tags for this Thread

None

Talk with us