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

Posted on 2006-04-18
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
    LVL 44

    Accepted Solution

    Hello ZabagaR,

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

    hope this helps a bit
    LVL 15

    Author Comment

    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

    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 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

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
    Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
    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…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    734 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

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now