Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

VB.NET Faces Off Against Classic VB : Page 8

VB.NET, the .NET Framework, and Visual Studio.NET together form a potent combination that can simplify your code and reduce errors; however, to truly supplant existing versions of VB as a RAD tool, Visual Studio needs Break-Edit-Continue.


advertisement

Launch another program and wait until it exits
Using the Shell command, it was easy to launch other Windows programs in classic VB, but they ran asynchronously. Pausing your program until the shelled application ended was much more difficult. Here are two examples that launch an instance of Notepad, wait until you close the window, and then display a message box confirming that the window was closed. The classic VB code is too long to include inline, but I borrowed the code from the MSDN Knowledge Base, so you can see a near-duplicate here. Note that there are other ways to accomplish the same result in VB.NET in addition to the method shown, which uses the VB.NET version of the Shell command.




Classic VB — see MSDN example.




VB.NET

   Private Sub btnLaunch_Click(ByVal sender As _
      System.Object, ByVal e As System.EventArgs) _
      Handles btnLaunch.Click
   
      Dim sysPath as String
      SysPath = System.Environment.GetFolderPath _
         (Environment.SpecialFolder.System)
      Shell(sysPath & "\notepad.exe", _
         AppWinStyle.NormalFocus, True)
      MessageBox.Show("You just closed Notepad", _
         "Notepad Closed")
   End Sub


Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap