Hi guys!
The code below actually works but I have a question about if there's another possible way to do this.
The above code is just another normal class. Somehow, my colleague's code works for some reason: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
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.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




Reply With Quote