Why does this happen?

  • (2 Pages)
  • +
  • 1
  • 2

16 Replies - 961 Views - Last Post: 06 May 2009 - 11:17 PM Rate Topic: -----

#1 Asscotte  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 35
  • View blog
  • Posts: 610
  • Joined: 08-February 09

Why does this happen?

Post icon  Posted 03 May 2009 - 12:35 PM

why does my code give me the answer of false? when I do have process running??? :(
		Dim e As String = ""
		Dim ps As System.Diagnostics.Process
		For Each ps In System.Diagnostics.Process.GetProcesses
			bl.Items.Add(ps.ToString)
		Next
		For Each item In bl.Items
			MsgBox(e = e + item.ToString)
		Next



Is This A Good Question/Topic? 0
  • +

Replies To: Why does this happen?

#2 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2241
  • View blog
  • Posts: 9,412
  • Joined: 29-May 08

Re: Why does this happen?

Posted 03 May 2009 - 02:54 PM

Two Questions.
1) Have you tried learning debugging skills;- Debugging
2) What do you think the .ToString returns?
Was This Post Helpful? 0
  • +
  • -

#3 specialfreckles  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 06-March 09

Re: Why does this happen?

Posted 03 May 2009 - 05:08 PM

This looks a lot like like a homework question.

Explain what you want to accomplish with your routine please
Was This Post Helpful? 0
  • +
  • -

#4 Asscotte  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 35
  • View blog
  • Posts: 610
  • Joined: 08-February 09

Re: Why does this happen?

Posted 04 May 2009 - 06:07 AM

View Postspecialfreckles, on 3 May, 2009 - 04:08 PM, said:

This looks a lot like like a homework question.

Explain what you want to accomplish with your routine please


its not a homework question :) im not even out of my second school yet :) but I copied it of a website and Im trying to get my program to email me with a list of process running of a remote computer seeing if one doesnt match ect then ending it if it doesnt. but I dont understand why i get the answer of false - thats why i posted :P
Was This Post Helpful? 0
  • +
  • -

#5 Asscotte  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 35
  • View blog
  • Posts: 610
  • Joined: 08-February 09

Re: Why does this happen?

Posted 06 May 2009 - 08:50 AM

*bump*

anyone?
Was This Post Helpful? 0
  • +
  • -

#6 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1639
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Why does this happen?

Posted 06 May 2009 - 09:05 AM

@Asscott: From that code I cant see where it should return true or false (maybe I haven't had enough coffee lol)
Was This Post Helpful? 0
  • +
  • -

#7 mark.bottomley  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 176
  • View blog
  • Posts: 990
  • Joined: 22-April 09

Re: Why does this happen?

Posted 06 May 2009 - 10:35 AM

you may want ps.Id or ps.ProcessName instead of ps.ToString to get the details you want.

the msgbox is showing False because you are asking it to show if e is equal to e concatentated with item.ToString - and they are not equal hence false. You likely want MsgBox("e = " & e & item.ToString)
Was This Post Helpful? 0
  • +
  • -

#8 Asscotte  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 35
  • View blog
  • Posts: 610
  • Joined: 08-February 09

Re: Why does this happen?

Posted 06 May 2009 - 12:34 PM

View Postmark.bottomley, on 6 May, 2009 - 09:35 AM, said:

you may want ps.Id or ps.ProcessName instead of ps.ToString to get the details you want.

the msgbox is showing False because you are asking it to show if e is equal to e concatentated with item.ToString - and they are not equal hence false. You likely want MsgBox("e = " & e & item.ToString)



thanks mark erm but how do I get rid of the other stuff because at the moment its coming up with e = {systems.diagnostics.process(VSHhost)} ? i would prefer just e = VSHHost
Was This Post Helpful? 0
  • +
  • -

#9 mark.bottomley  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 176
  • View blog
  • Posts: 990
  • Joined: 22-April 09

Re: Why does this happen?

Posted 06 May 2009 - 12:48 PM

Need 2 things - what type of control is "bl" and what selector are you using with ps - ProcessName? Then I will replicate and see.
Was This Post Helpful? 0
  • +
  • -

#10 Asscotte  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 35
  • View blog
  • Posts: 610
  • Joined: 08-February 09

Re: Why does this happen?

Posted 06 May 2009 - 01:00 PM

View Postmark.bottomley, on 6 May, 2009 - 11:48 AM, said:

Need 2 things - what type of control is "bl" and what selector are you using with ps - ProcessName? Then I will replicate and see.


Friend WithEvents bl As New ListView



and i dont know what you mean by selector all im using is this - Dim ps As System.Diagnostics.Process
Was This Post Helpful? 0
  • +
  • -

#11 mark.bottomley  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 176
  • View blog
  • Posts: 990
  • Joined: 22-April 09

Re: Why does this happen?

Posted 06 May 2009 - 01:24 PM

by selector - I mean when you add the ps data to items, what do you use.

bl.Items.Add(ps.ToString)

is in your original sample - i.e. you were using ToString as the selector on ps - are you still using it or something else?
Was This Post Helpful? 0
  • +
  • -

#12 Asscotte  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 35
  • View blog
  • Posts: 610
  • Joined: 08-February 09

Re: Why does this happen?

Posted 06 May 2009 - 01:34 PM

View Postmark.bottomley, on 6 May, 2009 - 12:24 PM, said:

by selector - I mean when you add the ps data to items, what do you use.

bl.Items.Add(ps.ToString)

is in your original sample - i.e. you were using ToString as the selector on ps - are you still using it or something else?



im using ps.processname :)
Was This Post Helpful? 0
  • +
  • -

#13 mark.bottomley  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 176
  • View blog
  • Posts: 990
  • Joined: 22-April 09

Re: Why does this happen?

Posted 06 May 2009 - 01:38 PM

you may have garbage in the e string - try MsgBox("e =" & item.ToString)

you can enable sorting on the listview to get the stuff back in an easy to compare order also.
Was This Post Helpful? 0
  • +
  • -

#14 Sethro117  Icon User is offline

  • Still the sexiest mofo.
  • member icon

Reputation: 236
  • View blog
  • Posts: 2,378
  • Joined: 14-January 09

Re: Why does this happen?

Posted 06 May 2009 - 01:43 PM

Im not sure what youre e is for, but I tried this and it worked:
		Dim ps As System.Diagnostics.Process
		For Each ps In System.Diagnostics.Process.GetProcesses
			bl.Items.Add(ps.ProcessName.ToString)
		Next
		Dim e1 As String = ""
		For Each item As ListViewItem In bl.Items
			MsgBox("e1 = " & item.Text.ToString)
		Next

This post has been edited by sh250080: 06 May 2009 - 01:44 PM

Was This Post Helpful? 0
  • +
  • -

#15 mark.bottomley  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 176
  • View blog
  • Posts: 990
  • Joined: 22-April 09

Re: Why does this happen?

Posted 06 May 2009 - 01:54 PM

it was your e from the original code - I don't know what you had it for :)
Anyways - success?!
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2