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

Visual Basic Help

syker

New Member
Joined
Sep 25, 2007
Messages
83 (0.01/day)
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

Moderator
Staff member
Joined
Nov 29, 2009
Messages
10,024 (1.91/day)
Location
Home
System Name Orange! // ItchyHands
Processor 3570K // 10400F
Motherboard ASRock z77 Extreme4 // TUF Gaming B460M-Plus
Cooling Stock // Stock
Memory 2x4Gb 1600Mhz CL9 Corsair XMS3 // 2x8Gb 3200 Mhz XPG D41
Video Card(s) Sapphire Nitro+ RX 570 // Asus TUF RTX 2070
Storage Samsung 840 250Gb // SX8200 480GB
Display(s) LG 22EA53VQ // Philips 275M QHD
Case NZXT Phantom 410 Black/Orange // Tecware Forge M
Power Supply Corsair CXM500w // CM MWE 600w
Insert the following function:

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

Example:

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

FordGT90Concept

"I go fast!1!11!1!"
Joined
Oct 13, 2008
Messages
26,259 (4.63/day)
Location
IA, USA
System Name BY-2021
Processor AMD Ryzen 7 5800X (65w eco profile)
Motherboard MSI B550 Gaming Plus
Cooling Scythe Mugen (rev 5)
Memory 2 x Kingston HyperX DDR4-3200 32 GiB
Video Card(s) AMD Radeon RX 7900 XT
Storage Samsung 980 Pro, Seagate Exos X20 TB 7200 RPM
Display(s) Nixeus NX-EDG274K (3840x2160@144 DP) + Samsung SyncMaster 906BW (1440x900@60 HDMI-DVI)
Case Coolermaster HAF 932 w/ USB 3.0 5.25" bay + USB 3.2 (A+C) 3.5" bay
Audio Device(s) Realtek ALC1150, Micca OriGen+
Power Supply Enermax Platimax 850w
Mouse Nixeus REVEL-X
Keyboard Tesoro Excalibur
Software Windows 10 Home 64-bit
Benchmark Scores Faster than the tortoise; slower than the hare.
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

New Member
Joined
Sep 25, 2007
Messages
83 (0.01/day)
Insert the following function:

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

Example:

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

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

Moderator
Staff member
Joined
Nov 29, 2009
Messages
10,024 (1.91/day)
Location
Home
System Name Orange! // ItchyHands
Processor 3570K // 10400F
Motherboard ASRock z77 Extreme4 // TUF Gaming B460M-Plus
Cooling Stock // Stock
Memory 2x4Gb 1600Mhz CL9 Corsair XMS3 // 2x8Gb 3200 Mhz XPG D41
Video Card(s) Sapphire Nitro+ RX 570 // Asus TUF RTX 2070
Storage Samsung 840 250Gb // SX8200 480GB
Display(s) LG 22EA53VQ // Philips 275M QHD
Case NZXT Phantom 410 Black/Orange // Tecware Forge M
Power Supply Corsair CXM500w // CM MWE 600w
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 :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

New Member
Joined
Sep 25, 2007
Messages
83 (0.01/day)
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.

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

syker

New Member
Joined
Sep 25, 2007
Messages
83 (0.01/day)
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:

FordGT90Concept

"I go fast!1!11!1!"
Joined
Oct 13, 2008
Messages
26,259 (4.63/day)
Location
IA, USA
System Name BY-2021
Processor AMD Ryzen 7 5800X (65w eco profile)
Motherboard MSI B550 Gaming Plus
Cooling Scythe Mugen (rev 5)
Memory 2 x Kingston HyperX DDR4-3200 32 GiB
Video Card(s) AMD Radeon RX 7900 XT
Storage Samsung 980 Pro, Seagate Exos X20 TB 7200 RPM
Display(s) Nixeus NX-EDG274K (3840x2160@144 DP) + Samsung SyncMaster 906BW (1440x900@60 HDMI-DVI)
Case Coolermaster HAF 932 w/ USB 3.0 5.25" bay + USB 3.2 (A+C) 3.5" bay
Audio Device(s) Realtek ALC1150, Micca OriGen+
Power Supply Enermax Platimax 850w
Mouse Nixeus REVEL-X
Keyboard Tesoro Excalibur
Software Windows 10 Home 64-bit
Benchmark Scores Faster than the tortoise; slower than the hare.
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

New Member
Joined
Sep 25, 2007
Messages
83 (0.01/day)
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

"I go fast!1!11!1!"
Joined
Oct 13, 2008
Messages
26,259 (4.63/day)
Location
IA, USA
System Name BY-2021
Processor AMD Ryzen 7 5800X (65w eco profile)
Motherboard MSI B550 Gaming Plus
Cooling Scythe Mugen (rev 5)
Memory 2 x Kingston HyperX DDR4-3200 32 GiB
Video Card(s) AMD Radeon RX 7900 XT
Storage Samsung 980 Pro, Seagate Exos X20 TB 7200 RPM
Display(s) Nixeus NX-EDG274K (3840x2160@144 DP) + Samsung SyncMaster 906BW (1440x900@60 HDMI-DVI)
Case Coolermaster HAF 932 w/ USB 3.0 5.25" bay + USB 3.2 (A+C) 3.5" bay
Audio Device(s) Realtek ALC1150, Micca OriGen+
Power Supply Enermax Platimax 850w
Mouse Nixeus REVEL-X
Keyboard Tesoro Excalibur
Software Windows 10 Home 64-bit
Benchmark Scores Faster than the tortoise; slower than the hare.
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
 
Top