?
Solved

VBS and VB simple question

Posted on 2003-02-24
3
Medium Priority
?
178 Views
Last Modified: 2010-04-07
Hi, I'm new here and i am currently learning
Visual Basic.
I was messing around writing a program in VBS with notepad
and i couldent use the shell command.
i allways get an error saying
type missmatch: "Shell"
i typed this into notepad and saved it as .vbs

Shell "C:\notepad.exe"

I got nothing, just an error.
But i can do it in a VB editor.
I have no idea why its doing that.
Thanks for your help!!
0
Comment
Question by:OverdrivE
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 300 total points
ID: 8007054
This is because not all functions available within VB are available with VBScript.

VBScript is designed for client side web browser scripting (though of course it can do many other things as well). As a result there are a number of limitations. For example there are no native file handling commands in vbscript, you cannot use API functions either. However many of the things that can be achieved in VB can be achieved in VBScript using alternative methods. For example the Shell command that you refer to can be achieved using this code:

Dim wshShell
Set wshShell = CreateObject("WScript.Shell")
wshShell.Run "c:\notepad.exe"
Set wshShell = Nothing

0
 

Author Comment

by:OverdrivE
ID: 8007071
Thank you very much!!!
:D :D
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 8008972
You need to accept a comment as answer now to close out this thread.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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
Course of the Month12 days, 7 hours left to enroll

777 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