I want to create a global function to use throughout my application. Let say it's about the connection to the database.
My code that i plan to use in my global function is:
myConnection = New SqlConnection("...........")
myConnection.Open()
So that I can call it to use in every form throughout my application. This can make me easy to edit the connection later.
Could anyone help me show how to define this global function and how to call this function in the form.
Best regard,
Public NotInheritable Class Utilities
Private Sub New()
End Sub
Public Shared Function MyMethod(myParam As Object) As MyObject
'Do stuff in here
Return New MyObject()
End Function
End Class
And then to consume
Dim instance As MyObject = Utilities.MyMethod(parameterObject)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With