Results 1 to 10 of 10

Thread: Open File (resolved)

  1. #1

    Thread Starter
    Lively Member smart_phil_dude1's Avatar
    Join Date
    Jun 2005
    Location
    Behind You!
    Posts
    125

    Resolved Open File (resolved)

    how would i be able to make a button on visual basic to open a certain file that is on my computer? what would be the code, etc.

    thnx in advance,
    Phil.D.
    Last edited by smart_phil_dude1; Jun 13th, 2005 at 07:55 PM. Reason: resolved
    Please Help Us Save Ana or donate now by going to Oneana.com

    Visit my Website at http://www.therealfantasy.com

  2. #2
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Re: Open File

    VB Code:
    1. Private Sub Command1_Click()
    2. Open C:\Desktop\Visual Basic.txt for Input as #1
    3.       Input, strYeaBaby
    4. Close #1
    5. End Sub

    to save:
    VB Code:
    1. Open C:\Desktop\Visual Basic.txt For Append as #1
    2.       Print, strYeaBabyGo
    3. Close #1

  3. #3
    Banned ThaRubby's Avatar
    Join Date
    Apr 2005
    Location
    127.0.0.1
    Posts
    356

    Re: Open File

    That would open a file and write to it, to open an executable file use the shell funtion.

    Shell "C:\Windows\System32\MSPaint.exe", vbHide

  4. #4
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Open File

    no, you need to use the ShellExecute function to open anything (anything with spaces in the name will give shell errors)

  5. #5

    Thread Starter
    Lively Member smart_phil_dude1's Avatar
    Join Date
    Jun 2005
    Location
    Behind You!
    Posts
    125

    Re: Open File

    well, if you put in %20 instead of a space, would it work?
    Please Help Us Save Ana or donate now by going to Oneana.com

    Visit my Website at http://www.therealfantasy.com

  6. #6
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Open File

    Nope. VB doesn't know what %20 is.

    You can, however, use it if the folder has no spaces:

    VB Code:
    1. Shell "C:\Windows\System32\MSPaint.exe \Images\myImage.bmp", vbHide

  7. #7
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Open File

    well actually, cant you wrap it in quotes?
    VB Code:
    1. Shell """C:\Windows\System32\MSPaint.exe \Images\myImage.bmp""", vbHide

  8. #8

    Thread Starter
    Lively Member smart_phil_dude1's Avatar
    Join Date
    Jun 2005
    Location
    Behind You!
    Posts
    125

    Re: Open File

    i've tried wrapping in quotes, and it works thnx |2eM!x, ThaRubby, dglienna, and paralinx for you guys' help.
    Please Help Us Save Ana or donate now by going to Oneana.com

    Visit my Website at http://www.therealfantasy.com

  9. #9
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Open File

    Quote Originally Posted by |2eM!x
    well actually, cant you wrap it in quotes?
    VB Code:
    1. Shell """C:\Windows\System32\MSPaint.exe \Images\myImage.bmp""", vbHide

    It works as is. No double quotes needed.

  10. #10
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Open File (resolved)

    my bad, but it was an example for spaces.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width