Microsoft Visual Basic .NET HowTo

Launching an Application

The following example will launch Microsoft Visual C++ 6.0 if it is installed in the computer:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        System.Diagnostics.Process.Start("C:\\Program Files\\Microsoft Visual Studio\\Common\\MSDev98\\Bin\\msdev.exe")
End Sub

Open a Microsoft Excel Workbook

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim MSExcelApp As Object
        Dim MSXLWorkbook As Object
        Dim MSExcelWorksheet As Object

        ' Create an instance of Microsoft Excel
        MSExcelApp = CreateObject("Excel.Application")
        ' Create a workbook
        MSXLWorkbook = MSExcelApp.Workbooks.Add
        ' Identify the workbook you will use
        MSExcelWorksheet = MSXLWorkbook.Worksheets(1)
        MSExcelWorksheet.Activate()
        ' Display MS Excel
        MSExcelWorksheet.Application.Visible = True
        ' Do some things in cells
        ' Cell B2
        MSExcelWorksheet.Cells(2, 2) = "Arithmetic"
        ' Cell B3
        MSExcelWorksheet.Cells(3, 2) = "244.62"
        ' Cell B4
        MSExcelWorksheet.Cells(4, 2) = "1450.55"
    End Sub

 

Home