Home All Groups Group Topic Archive Search About
Author
5 Dec 2006 3:55 AM
encino1030
I have only slightly tried to learn VB, and have been trying to do
something vith VB.net.

I am sure it is simple to some (probably most), but please bear with
me.

I want to creat a form with various buttons.  each button will load a
file on the same CD that the exe file is on.
nothing fancy, just launch some .doc, .xls and PDF files.
second issue, I want to be able to load these files regarless of the CD
drive letter the user may have assigned to the drive.

I am just trying to learn some simple stuff, and am at a complete loss.

If someone has the time to walk me through the process, I would
appreciate it.

Thank you for your help

Author
5 Dec 2006 4:18 AM
Dylan Copeland
Try using this.

Dim pth as String = InputBox("What letter is your CD Drive assigned to?
Please use this format: "X".")
Process.Start(pth & ":\path to file.doc")

I hope this helps.
Show quoteHide quote
"encino1***@yahoo.com" wrote:

> I have only slightly tried to learn VB, and have been trying to do
> something vith VB.net.
>
> I am sure it is simple to some (probably most), but please bear with
> me.
>
> I want to creat a form with various buttons.  each button will load a
> file on the same CD that the exe file is on.
> nothing fancy, just launch some .doc, .xls and PDF files.
> second issue, I want to be able to load these files regarless of the CD
> drive letter the user may have assigned to the drive.
>
> I am just trying to learn some simple stuff, and am at a complete loss.
>
> If someone has the time to walk me through the process, I would
> appreciate it.
>
> Thank you for your help
>
>
Author
5 Dec 2006 5:06 AM
Cor Ligthert [MVP]
First start to have a view what kind of controls are there in VB.Net

Mostly their is already a sufficient Control and than their are even more in
so called powertools or sold by 3th part vendors.

For this you can have a look at the openfiledialog
http://msdn2.microsoft.com/en-us/library/system.windows.forms.openfiledialog(VS.80).aspx

I hope this helps,

Cor


<encino1***@yahoo.com> schreef in bericht
Show quoteHide quote
news:1165290943.133005.8220@73g2000cwn.googlegroups.com...
>I have only slightly tried to learn VB, and have been trying to do
> something vith VB.net.
>
> I am sure it is simple to some (probably most), but please bear with
> me.
>
> I want to creat a form with various buttons.  each button will load a
> file on the same CD that the exe file is on.
> nothing fancy, just launch some .doc, .xls and PDF files.
> second issue, I want to be able to load these files regarless of the CD
> drive letter the user may have assigned to the drive.
>
> I am just trying to learn some simple stuff, and am at a complete loss.
>
> If someone has the time to walk me through the process, I would
> appreciate it.
>
> Thank you for your help
>
Author
5 Dec 2006 11:28 AM
Oenone
encino1***@yahoo.com wrote:
> I want to creat a form with various buttons.  each button will load a
> file on the same CD that the exe file is on.
> nothing fancy, just launch some .doc, .xls and PDF files.

This should be fairly straightforward...

Create your form and add the buttons you want to use to launch the files.
Lay them all out and set their properties however you want.

Double-click one of the buttons to open up its Click event handled in the
code editor. Paste in the following code:

\\\
    Dim filename As String

    'Get the drive the running EXE was launched from
    filename = IO.Path.GetPathRoot(Assembly.GetExecutingAssembly.Location)

    'Append the name of the file to open
    filename &= "Test.doc"

    'Launch the file
    Process.Start(filename)

///

This code first gets the root path of the running executable. If it's
running from the CD-ROM drive, this will be the letter of that drive. It is
returned in the format "X:\".

The filename to be opened ("Test.doc" in this case) is then appended. Change
this for each button to be whatever you need. Include subdirectories too if
required (e.g., "MyFolder/MyFile.pdf").

Finally, Process.Start() is used to instruct Windows to open the file in the
appropriate file viewer. If no viewer is registered for the file type, this
will throw an exception so be prepared to catch it in this case. With a
little more work you can prompt the user to select which viewer to use under
these circumstances -- take a look at the documentation for the
System.Diagnostics.Process class for more info, and in particular the
ErrorDialog property.

HTH,

--

(O)enone
Author
6 Dec 2006 3:13 AM
Donna Hansen
I will try this.  Thank you for your help.  Like I said, I am trying to
teach myself and will be looking for help frequently I am sure.

Thanks again

Show quoteHide quote
"Oenone" <oen***@nowhere.com> wrote in message
news:u%23PJGCGGHHA.924@TK2MSFTNGP02.phx.gbl...
> encino1***@yahoo.com wrote:
>> I want to creat a form with various buttons.  each button will load a
>> file on the same CD that the exe file is on.
>> nothing fancy, just launch some .doc, .xls and PDF files.
>
> This should be fairly straightforward...
>
> Create your form and add the buttons you want to use to launch the files.
> Lay them all out and set their properties however you want.
>
> Double-click one of the buttons to open up its Click event handled in the
> code editor. Paste in the following code:
>
> \\\
>    Dim filename As String
>
>    'Get the drive the running EXE was launched from
>    filename = IO.Path.GetPathRoot(Assembly.GetExecutingAssembly.Location)
>
>    'Append the name of the file to open
>    filename &= "Test.doc"
>
>    'Launch the file
>    Process.Start(filename)
>
> ///
>
> This code first gets the root path of the running executable. If it's
> running from the CD-ROM drive, this will be the letter of that drive. It
> is returned in the format "X:\".
>
> The filename to be opened ("Test.doc" in this case) is then appended.
> Change this for each button to be whatever you need. Include
> subdirectories too if required (e.g., "MyFolder/MyFile.pdf").
>
> Finally, Process.Start() is used to instruct Windows to open the file in
> the appropriate file viewer. If no viewer is registered for the file type,
> this will throw an exception so be prepared to catch it in this case. With
> a little more work you can prompt the user to select which viewer to use
> under these circumstances -- take a look at the documentation for the
> System.Diagnostics.Process class for more info, and in particular the
> ErrorDialog property.
>
> HTH,
>
> --
>
> (O)enone
>