VB 6 doesn't like "objProcess.Terminate()" ???

Posted on 2006-04-18
Medium Priority
Last Modified: 2010-05-18
I have a small script called "terminate.vbs" that I run by double-clicking on it.
But, if I use it in MS-Visual Basic 6 it won't run or compile.  It doesn't like the line "objProcess.Terminate()".
The line also is colored red like a syntax error.  Why is that?

here's a clip - at the bottom is the line
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _
    ("Select * from Win32_Process Where Name = 'Notepad.exe'")
For Each objProcess in colProcessList
Question by:ZabagaR
  • 2
LVL 44

Accepted Solution

bruintje earned 2000 total points
ID: 16482187
Hello ZabagaR,

take out the () it says to VB that it is expecting input

hope this helps a bit
LVL 15

Author Comment

ID: 16487563
Thanks.  That worked.  I just don't understand why it would differ between the .vbs text-file version the same code under VB6.
I'd expect it to be the same...maybe without the "()" in both.

Did you know because you looked it up somewhere or just from experience?  I searched the internet for a bit, trying to find an explanation but never found one.
(which is why I ended up posting here).

Thanks again,
LVL 44

Expert Comment

ID: 16487824
its the difference in syntax, this is something you see after walking through the vb dialects, vb, vbs and vba and luckily for us its vb.net now so more of the same little syntax differences to keep up with :-)

but i tested it first in Excel VBA before posting :)

thanks for the grade

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

750 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