Launching NotePad App... how?

Hi,
  I would like to ask how do I launch NotePad application and automatically open , say "test.txt" from my VB program?
I don't have any Win API reference so I hope u guys can help me out.. thanks!
A simple eample would be very useful.. :)
Haho2Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dr. Kamal MehdiCommented:
Use the ShellExecute API function.
I will post you the code in a comment.
Regards
Dr. Kamal MehdiCommented:
Put the following declaration in a module (.BAS):

    Declare Function ShellExecute Lib _
    "shell32.dll" Alias "ShellExecuteA" _
    (ByVal hwnd As Long, _
    ByVal lpOperation As String, _
    ByVal lpFile As String, _
    ByVal lpParameters As String, _
    ByVal lpDirectory As String, _
    ByVal nShowCmd As Long) As Long


Call the function from your form after specifying the full path/name of the .txt file:

    RetVal = ShellExecute(0&, 0&, FileName, vbNullString, vbNullString, WindowState)


The WindowState is:
 1 = Normal
 2 = Minimized
 3 = maximized

Regards
Haho2Author Commented:
thanks kamall
  but I was thinking of doing it by creating it as a wordpad/notepad object and then opening it. Can anybody tell me how to do it?
the reason is that it seems more professional?! Thanks again, kamall

 

Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

danielmarkusCommented:
You can't use a notepad object, since it is not an activeX object. It is simply an executable object. You have to recreate notepad. Fortunately this can be done with a simple textbox with the multiline property set to true. Than you need to add some code.

There is already a very nice sample of this. It is in the samples directory of your vb directory. If everything is installed in the standard way it should be in:
C:\Program Files\DevStudio\VB\samples\PGuide\SDI
The program is called SDI and it contains a very nice implementation of notepad.

Good luck

Daniel

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dr. Kamal MehdiCommented:
danielmarkus,
You could have posted your answer as a comment.

Haho2,
Simply, it is not possible because the notepad is a normal EXE.
Please reject the current answer to enable me to relcok the question and get the points. Thanks.

Regards to all.
danielmarkusCommented:
Look all,

It is not about the lousy points. Looking at this discussion I see a vague question with a clear and correct, however rejected answer, because the asker, wanted something else. Than I gave an other answer, which is defnitely correct.
Don't you going to tell me, Kamal, how I should post my answers. Bother someone else please.
Further I don't care about this nuisance and petty newby bull that you're exchanging. But comments like yours are the lowest I've come across so far in my online life. I hope you choke in your 40 points.

Good bye,

Daniel
Dr. Kamal MehdiCommented:
It seems that I stepped on your tail Mr. Daniel!
Since you know that my answer was clear and correct, why did you post an answer rather than posting a comment?
And finally, what was the 'lowest...' in my comment?
Be more polite here and respect others or better do not re-enter here at all because you will hear 'much much lower' comments than mine.

Haho2, sorry for the comment, but I had to respond to 'Mr. Daniel' for his impolite words.
Regards
Haho2Author Commented:
Thanks to both of you...
I appreciate that you both have given me the answer and other comments but I really don't see the need to "fight" over who gets the points.. after all, 40 is not that many points..
thanks again ...
Dr. Kamal MehdiCommented:
Haho2,
The issue is not really the points, but rather it is the way an 'expert' should react when he see an answer that is correct but was rerjected because probably the question was not so clear. In such cases, experts always submit a comment showing that the rejected answer was really correct and we give our openions and suggestions. That is the reason why danielmarkus should have posted his answer as a comment.
Anyway,
If you like to grade him, its up to you to decide. If you don't grade his answer and leave it, he will be graded automatically by the system after some it and you will lose the points.
So you have the following options:
Either reject his answer and refund your points, or
leave it as is and he will be graded automatically, or
if you would like to grade me, you should reject the current answer and leave me a comment.

Best regards
Dr. Kamal MehdiCommented:
Haho2,
The issue is not really the points, but rather it is the way an 'expert' should react when he see an answer that is correct but was rerjected because probably the question was not so clear. In such cases, experts always submit a comment showing that the rejected answer was really correct and we give our openions and suggestions. That is the reason why danielmarkus should have posted his answer as a comment.
Anyway,
If you like to grade him, its up to you to decide. If you don't grade his answer and leave it, he will be graded automatically by the system after some time and you will lose the points.
So you have the following options:
Either reject his answer and refund your points, or
leave it as is and he will be graded automatically, or
if you would like to grade me, you should reject the current answer and leave me a comment.

Best regards
Dr. Kamal MehdiCommented:
Oops, sent twice.... sorry.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.