# Visual Basic Help



## syker (Jun 2, 2010)

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.


----------



## Fourstaff (Jun 2, 2010)

Insert the following function:

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

Example:

Shell ("C:/Notepad.exe",vbmaximized)


----------



## FordGT90Concept (Jun 2, 2010)

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...


```
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 (Jun 21, 2010)

Fourstaff said:


> Insert the following function:
> 
> Shell(<enter file path of program>,<Window State of program to be opened>)
> 
> ...



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.


----------



## Fourstaff (Jun 21, 2010)

syker said:


> 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.



I never typed that  I think my friend must have seen that post and proceeded to help you out  I am sorry I am of no help when it comes to Visual Basic  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 (Jun 21, 2010)

Fourstaff said:


> I never typed that  I think my friend must have seen that post and proceeded to help you out  I am sorry I am of no help when it comes to Visual Basic  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.



well, it worked, nevertheless. so thank him for me when you get the chance.


----------



## syker (Jun 22, 2010)

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.


----------



## FordGT90Concept (Jun 22, 2010)

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")


----------



## syker (Jun 22, 2010)

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.


----------



## FordGT90Concept (Jun 22, 2010)

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


----------

