Help with creating tool

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Thew
    New Member
    • Aug 2010
    • 69

    Help with creating tool

    Hi

    i am new to visual basic. So i am gonna need some help creating a tool.

    what i want:

    A tool with 1 text field, and 3 buttons.

    If you press button 1, there will be a prompt box, to select a file (all files are clickable). If you select one, the content of the file will be shown in the text area. Then you can edit the text. Then when you press button 2, the file will be saved. When you didnt selected a file with button 1, there will be created a new file. When you press button 3, you will go to a website.

    Now i already created the tool itself, but now the code.
    Thats where i need help with.

    I already found some code for button 3:

    Code:
    Private Sub Command3_Click()
    System.Diagnostics.Process.Start ("http://www.thewnetwork.tk/")
    End Sub
    but that didnt work. it gave this error:

    Runtime error 424
    Object required

    i am using VB6

    Thanks,
    Thew
  • Guido Geurs
    Recognized Expert Contributor
    • Oct 2009
    • 767

    #2
    This opens IE to the URL=

    Code:
    Shell "C:\Program Files\Internet Explorer\IEXPLORE.EXE http://www.thewnetwork.tk", vbMaximizedFocus

    Comment

    • Thew
      New Member
      • Aug 2010
      • 69

      #3
      With is the problem: Not everyone has IE on his PC or has IE on drive C:\. For example, i have IE on drive D:\.

      Comment

      • TamusJRoyce
        New Member
        • Apr 2008
        • 108

        #4
        I believe the command you are looking for is Shell and not Start?

        Shell("http://www.thewnetwork .tk/", vbNormalFocus)

        But ggeu had the right idea. IE isn't always located in the C drive either.

        Comment

        • Guido Geurs
          Recognized Expert Contributor
          • Oct 2009
          • 767

          #5
          If the settings are on each PC different, than You have to save them in a file.
          Attached is an example how to do this.
          Attached Files

          Comment

          • TamusJRoyce
            New Member
            • Apr 2008
            • 108

            #6
            qqeu, have you used environment variables before?

            try:
            Code:
            Shell "$ProgramFiles\Internet Explorer\IEXPLORE.EXE http://www.thewnetwork.tk", vbMaximizedFocus
            But this still doesn't open the default web browser if it isn't IE, or IE is uninstalled (some versions of windows 7 don't come with it installed!).

            Any ideas, qqeu? I'm assuming Shell("http://www.thewnetwork .tk/", vbNormalFocus) doesn't work as documented.

            Comment

            • Guido Geurs
              Recognized Expert Contributor
              • Oct 2009
              • 767

              #7
              Because the Explorer is not always the same and on different places, You have to save this path and filename of the browser in a file (settings.ini) with the command "Com_Settin gs" and the form "ExplorerSettin gs".

              In the settings.ini file must be for You:
              "D:\.......\IEX PLORER.EXE"
              For an other PC: maybe= "C:\progr...\fi refox.exe"

              At the start of the program, the setting will be loaded into the textbox of the form "ExplorerSettin gs".

              The line =
              Code:
                 Shell ExplorerSettings.Text_ExplorerPrg & " " & "http://www.thewnetwork.tk", vbMaximizedFocus
              uses the text from this textbox to open the dedicated Explorer (IE, FireFox, ...) and the URL.

              Comment

              • TamusJRoyce
                New Member
                • Apr 2008
                • 108

                #8
                Using a .ini file you have to modify doesn't seem helpful enough.

                There was a time where you had to search the windows registry to find the location and application you wished to execute. But that was back with Win16 API for Windows 3.1. Otherwise, the only other choice was using an .ini file approach.

                I don't believe that NT based Windows has these global .ini files like settings.ini around anymore. If they do, they are legacy and can't be considered correct or to contain the information you may want.

                But a better solution would be to find the command to tell Windows to open the website in question (Win95 and above), and Windows will choose the correct browser.

                Otherwise, maybe someone else has some idea's?

                Comment

                • TamusJRoyce
                  New Member
                  • Apr 2008
                  • 108

                  #9
                  I knew if I thought about it long enough I would remember it...

                  Code:
                  Shell("rundll32.exe shell32.dll,ShellExec_RunDLL http://www.thewnetwork.tk/", vbNormalFocus)
                  http://www.vbaccelerator.com/codelib/shell/shellex.htm is an article that gives an example of importing shell32.dll and using ShellExec directly for vb6, if you would rather not rely on rundll32.exe

                  Comment

                  • TamusJRoyce
                    New Member
                    • Apr 2008
                    • 108

                    #10
                    This rundll32.exe trick doesn't seem to be working for windows 7. Does anyone know one that will? or I will post one if I find it.

                    Ah. Well, the rundll works in a pinch if you only need to support <= windows xp, but System.Diagnost ics.Process.Sta rt("http://www.thewnetwork .tk/") is what you typically want.

                    Comment

                    Working...