1. Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Visual Basic Help

Discussion in 'Programming & Webmastering' started by syker, Jun 2, 2010.

  1. syker New Member

    Joined:
    Sep 25, 2007
    Messages:
    83 (0.03/day)
    Thanks Received:
    2
    what is the code to open a program from the mouse-click of a button? i have tried a few different codes, but none of them seem to be working.
     
  2. Fourstaff

    Fourstaff Moderator Staff Member

    Joined:
    Nov 29, 2009
    Messages:
    9,212 (4.98/day)
    Thanks Received:
    1,995
    Location:
    Home
    Insert the following function:

    Shell(<enter file path of program>,<Window State of program to be opened>)

    Example:

    Shell ("C:/Notepad.exe",vbmaximized)
     
    syker says thanks.
  3. FordGT90Concept

    FordGT90Concept "I go fast!1!11!1!"

    Joined:
    Oct 13, 2008
    Messages:
    14,105 (6.24/day)
    Thanks Received:
    3,923
    Location:
    IA, USA
    Right-click, as far as I know, always triggers the associated ContextMenuStrip. Whatever control you are right-clicking on therefore needs a ContextMenuStrip assigned to its .ContextMenuStrip or .ContextMenu property. You'll most likely have to have a button in that ContextMenuStrip which, when clicked, executes your program.

    As for launching programs, first you need "Imports System.Diagnostics" (no quotes) at the top of the .vb file. To start it, do Process.Start(path, arguments) or...

    Code:
    Dim psi As New ProcessStartInfo(path, arguments)
    With psi
      .ShellExecute = false
      .CreateNoWindow = true
      .etc
    End With
    Process.Start(psi)
    Process has a lot of goodies in it so you might want to store the result of start in a variable for use later.
     
    syker says thanks.
    Crunching for Team TPU
  4. syker New Member

    Joined:
    Sep 25, 2007
    Messages:
    83 (0.03/day)
    Thanks Received:
    2
    when you say "Window State of program to be opened" what specifically do you mean?
    your example said "vbmaximized". Notepad isnt Visual Basic, so what does the "vb" mean?

    i am not second-guessing your ability to give good codes, just making sure that everything is secure and this code won't blow up in my face.
     
  5. Fourstaff

    Fourstaff Moderator Staff Member

    Joined:
    Nov 29, 2009
    Messages:
    9,212 (4.98/day)
    Thanks Received:
    1,995
    Location:
    Home
    I never typed that :wtf: I think my friend must have seen that post and proceeded to help you out :ohwell: I am sorry I am of no help when it comes to Visual Basic :eek: I think he refers to either full screen or just a small window. I have no idea what he means by the phrase "vbmaximised". Will come to you if I meet him again.

    Edit: He says that it refers to the initial state of the window, ie maximised or minimised (in the taskbar). The "vb" is just the code.
     
    syker says thanks.
  6. syker New Member

    Joined:
    Sep 25, 2007
    Messages:
    83 (0.03/day)
    Thanks Received:
    2
    well, it worked, nevertheless. so thank him for me when you get the chance.
     
  7. syker New Member

    Joined:
    Sep 25, 2007
    Messages:
    83 (0.03/day)
    Thanks Received:
    2
    another question: what is an easy, affordable (preferrably free), way to convert VB10 to EXE? i already tried iexpress.exe but it didnt quite work.
     
    Last edited: Jun 22, 2010
  8. FordGT90Concept

    FordGT90Concept "I go fast!1!11!1!"

    Joined:
    Oct 13, 2008
    Messages:
    14,105 (6.24/day)
    Thanks Received:
    3,923
    Location:
    IA, USA
    Doubt there is a way. VBS is based on VB6--both of which are incompatible with Visual Basic .NET (7-10). VBS generally needs to be reprogrammed into VB.NET.


    Edit: Maybe you can run them directly with the code I posted before. For example:

    System.Diagnostics.Process.Start("C:\oldvbscript.vbs")
     
    Crunching for Team TPU
  9. syker New Member

    Joined:
    Sep 25, 2007
    Messages:
    83 (0.03/day)
    Thanks Received:
    2
    ok, i found out a way. under "Project" you will find a drop-down item called "Publish <name of document>". click that, then click "finish" on the first page of the popup. then you have a home-made program that you can put on your desktop.
     
  10. FordGT90Concept

    FordGT90Concept "I go fast!1!11!1!"

    Joined:
    Oct 13, 2008
    Messages:
    14,105 (6.24/day)
    Thanks Received:
    3,923
    Location:
    IA, USA
    Oh, VB10. You can build it by right-clicking on the project and selecting Build or you can do the same by going to the Build menu up at the top. Running the app also often triggers a build. Whenever it builds, you can find the finished product in <Project Name>\bin\<Configuration>\<Assembly Name>.exe or .dll

    For example, if your project name is "Foo", you did a Debug build, and the Assembly Name is "FooBar", the path to the executable would be:

    Foo\bin\Debug\FooBar.exe
     
    Crunching for Team TPU

Currently Active Users Viewing This Thread: 1 (0 members and 1 guest)

Share This Page