• 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.02/day)
Likes
2
#1
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
9,382 (3.15/day)
Likes
2,103
Location
Home
System Name Asus K50-X5DAB \\ Orange!
Processor Athlon QL-65 2.2Ghz \\ 3570K
Motherboard Laptop \\ ASRock z77 Extreme4
Cooling Laptop \\ H100i
Memory 1x1GB + 1X2GB \\ 2x4Gb 1600Mhz CL9 Corsair XMS3
Video Card(s) Mobility Radeon HD4570 512mb \\ Zotac 660Ti OC 2Gb
Storage 250Gb \\ Samsung 840 250Gb + Toshiba DT01ACA300 3Tb
Display(s) 15.6" 1366x768 \\ LG 22EA53VQ
Case Laptop Chassis \\ NZXT Phantom 410 Black/Orange
Power Supply Power Brick \\ Corsair CXM500w
#2
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
21,101 (6.22/day)
Likes
10,230
Location
IA, USA
System Name BY-2015
Processor Intel Core i7-6700K (4 x 4.00 GHz) w/ HT and Turbo on
Motherboard MSI Z170A GAMING M7
Cooling Scythe Kotetsu
Memory 2 x Kingston HyperX DDR4-2133 8 GiB
Video Card(s) PowerColor PCS+ 390 8 GiB DVI + HDMI
Storage Crucial MX300 275 GB, Seagate 6 TB 7200 RPM
Display(s) Samsung SyncMaster T240 24" LCD (1920x1200 HDMI) + Samsung SyncMaster 906BW 19" LCD (1440x900 DVI)
Case Coolermaster HAF 932 w/ USB 3.0 5.25" bay
Audio Device(s) Realtek Onboard, Micca OriGen+
Power Supply Enermax Platimax 850w
Mouse SteelSeries Sensei RAW
Keyboard Tesoro Excalibur
Software Windows 10 Pro 64-bit
Benchmark Scores Faster than the tortoise; slower than the hare.
#3
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.02/day)
Likes
2
#4
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
9,382 (3.15/day)
Likes
2,103
Location
Home
System Name Asus K50-X5DAB \\ Orange!
Processor Athlon QL-65 2.2Ghz \\ 3570K
Motherboard Laptop \\ ASRock z77 Extreme4
Cooling Laptop \\ H100i
Memory 1x1GB + 1X2GB \\ 2x4Gb 1600Mhz CL9 Corsair XMS3
Video Card(s) Mobility Radeon HD4570 512mb \\ Zotac 660Ti OC 2Gb
Storage 250Gb \\ Samsung 840 250Gb + Toshiba DT01ACA300 3Tb
Display(s) 15.6" 1366x768 \\ LG 22EA53VQ
Case Laptop Chassis \\ NZXT Phantom 410 Black/Orange
Power Supply Power Brick \\ Corsair CXM500w
#5
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.02/day)
Likes
2
#6
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.02/day)
Likes
2
#7
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
21,101 (6.22/day)
Likes
10,230
Location
IA, USA
System Name BY-2015
Processor Intel Core i7-6700K (4 x 4.00 GHz) w/ HT and Turbo on
Motherboard MSI Z170A GAMING M7
Cooling Scythe Kotetsu
Memory 2 x Kingston HyperX DDR4-2133 8 GiB
Video Card(s) PowerColor PCS+ 390 8 GiB DVI + HDMI
Storage Crucial MX300 275 GB, Seagate 6 TB 7200 RPM
Display(s) Samsung SyncMaster T240 24" LCD (1920x1200 HDMI) + Samsung SyncMaster 906BW 19" LCD (1440x900 DVI)
Case Coolermaster HAF 932 w/ USB 3.0 5.25" bay
Audio Device(s) Realtek Onboard, Micca OriGen+
Power Supply Enermax Platimax 850w
Mouse SteelSeries Sensei RAW
Keyboard Tesoro Excalibur
Software Windows 10 Pro 64-bit
Benchmark Scores Faster than the tortoise; slower than the hare.
#8
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.02/day)
Likes
2
#9
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
21,101 (6.22/day)
Likes
10,230
Location
IA, USA
System Name BY-2015
Processor Intel Core i7-6700K (4 x 4.00 GHz) w/ HT and Turbo on
Motherboard MSI Z170A GAMING M7
Cooling Scythe Kotetsu
Memory 2 x Kingston HyperX DDR4-2133 8 GiB
Video Card(s) PowerColor PCS+ 390 8 GiB DVI + HDMI
Storage Crucial MX300 275 GB, Seagate 6 TB 7200 RPM
Display(s) Samsung SyncMaster T240 24" LCD (1920x1200 HDMI) + Samsung SyncMaster 906BW 19" LCD (1440x900 DVI)
Case Coolermaster HAF 932 w/ USB 3.0 5.25" bay
Audio Device(s) Realtek Onboard, Micca OriGen+
Power Supply Enermax Platimax 850w
Mouse SteelSeries Sensei RAW
Keyboard Tesoro Excalibur
Software Windows 10 Pro 64-bit
Benchmark Scores Faster than the tortoise; slower than the hare.
#10
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