Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27189

VB2010: Calling another sub procedure

$
0
0
Hi guys!

The code below actually works but I have a question about if there's another possible way to do this.
Code:

Imports System.Data.SqlClient
Imports Microsoft.Office.Interop
Public Class clsPrint

    Dim oXLApp As Excel.Application
    Dim oXLBook As Excel.Workbook
    Dim oSheet As Excel.Worksheet
    Dim oRng As Excel.Range

    Public Sub print()

        oXLApp = CreateObject("Excel.Application")
        oXLApp.Visible = True

        oXLBook = oXLApp.Workbooks.Add
        oSheet = oXLBook.ActiveSheet

    End Sub

    Public Sub pManagement()
        'Some codes here
    End Sub

    Public Sub pUser()
        'Some codes here
    End Sub

End Class

The above code is just another normal class. Somehow, my colleague's code works for some reason:

Code:

    Private Sub butPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butPrint.Click
        Dim printMe As New clsPrint
        printMe.print()
        printMe.pManagement()
    End Sub

My question is that is it possible to create a function that goes through the "Public Sub print()" and add some parameters there to call the other sub procedures like the "pManagement" or the "pUser" so that the code in the button shortens one line like this:

Code:

    Private Sub butPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butPrint.Click
        Dim printMe As New clsPrint
        printMe.print(printme.pManagement)
    End Sub

I tried looking at the parameter's list but I can't seem to find an idea what kind of parameter I am looking for.

Viewing all articles
Browse latest Browse all 27189

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>