Jump to content
xisto Community
Aeon

Msgbox Question.

Recommended Posts

Hey,
I was wondering that the appropriate syntax would be to have VB run an application when you hit 'okay' -- Meaning when you hit okay, it opens up notepad.exe or whatever.

My current code is

msgbox "Some message here", 0
I've tried adding Open="notepad.exe" on the next line, but it does not work.

Any feedback would be greatly appreciated.

-AE.
Edited by Aeon (see edit history)

Share this post


Link to post
Share on other sites

It depends on what version of VB you're using. If your using VB.NET, use the line of code:Process.Start("Notepad.exe")That line of code, without giving the drive letter or folder information, will open a windows exe located in your system32 folder.To run a program other than a system32 application, use code similar to this:Process.Start("c:\folder\myapp.exe")These lines of code won't work if your using VB6.

Share this post


Link to post
Share on other sites

It depends on what version of VB you're using. If your using VB.NET, use the line of code:
Process.Start("Notepad.exe")

That line of code, without giving the drive letter or folder information, will open a windows exe located in your system32 folder.
To run a program other than a system32 application, use code similar to this:

Process.Start("c:\folder\myapp.exe")

These lines of code won't work if your using VB6.


Thank you.

I am using VB6 though, so the code does not work. Would it be better to upgrade to .net?

Share this post


Link to post
Share on other sites

Thank you.
I am using VB6 though, so the code does not work. Would it be better to upgrade to .net?


If you're using VB6, use this code instead.


Dim ReturnVal

ReturnVal = Shell("C:\WINDOWS\System32\notepad.exe", 1)


With VB6, you need the entire URL to the EXE even with system32 processes. I've forgotten some of my version 6 knowledge, but I do believe the 1 after the exe name is for when your handling multiple processes, you change the number incrementally. I may be wrong on that though.

Share this post


Link to post
Share on other sites

If you're using VB6, use this code instead.

 

 

Dim ReturnVal

 

ReturnVal = Shell("C:\WINDOWS\System32\notepad.exe", 1)

 

 

With VB6, you need the entire URL to the EXE even with system32 processes. I've forgotten some of my version 6 knowledge, but I do believe the 1 after the exe name is for when your handling multiple processes, you change the number incrementally. I may be wrong on that though.


Hmm---

It's giving me an error with that code--

 

 

msgbox "Messagehere", 0Dim ReturnValReturnVal = Shell("C:\WINDOWS\System32\notepad.exe", 1)

Error Information:

 

Line 4

Char 1

Error: Type mismatch: 'Shell'

Code: 800A000D

Source: Microsoft VBScript runtime error.

 

I should note that I'm coding this with notepad.

Share this post


Link to post
Share on other sites

Are you using VB6 or VBScript? There is a difference.If your coding this in notepad, im assuming your using VBScript? In that case im not sure how to Shell an application =/ sorry.

Share this post


Link to post
Share on other sites

I am not sure if this has been resolved yet or not. But for the sake of anyone searching the topic here is a resolution. This is VB Script.

Set objShell = CreateObject("WScript.Shell")objShell.Run "%windir%\Notepad.exe"

If you are using the option explicit you have to add the line :

dim objShell

first to declare the variable.

Hope this helps someone.
Edited by darasen (see edit history)

Share this post


Link to post
Share on other sites
retrieve msgbox textMsgbox Question.

I was wondering if anyone knows how to retrieve the text from a msgbox from another process?Is there a "Get" statement that I can use?

-reply by mark

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.