Browse DevX
Sign up for e-mail newsletters from DevX


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.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

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.


   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 _
      Shell(sysPath & "\notepad.exe", _
         AppWinStyle.NormalFocus, True)
      MessageBox.Show("You just closed Notepad", _
         "Notepad Closed")
   End Sub

Thanks for your registration, follow us on our social networks to keep up-to-date