How to show the same item you doing throughout the whole app?
I am doing an account editing application.
I had like my applications to be doing on the same account, be it in my main form or in other forms (debit, credit, paymen etc), but still doing on the same account.
So, how can I implement my form/code to be doing on the same account unless user selected other accounts, throughout the whole app?
I heard and seen that arguements or methods in your coding, how do you do that?
Re: How to show the same item you doing throughout the whole app?
You need to declare the account object in a Module so that it can accessed from anywhere in the application.
Re: How to show the same item you doing throughout the whole app?
A module? Could you explain to me in detail how to do it?
Sorry for the inconvenience caused.
Re: How to show the same item you doing throughout the whole app?
Quote:
Originally Posted by melvados
A module? Could you explain to me in detail how to do it?
Sorry for the inconvenience caused.
Sometimes you need to create functions that are of generic in nature. Lets say you need a function which should give you a random number between specified range. So you will create a function to generate a random number and put into a module. Once you write this function in a module, you will be able to call it from anywhere.
A module is declared with Module, End Module pair. You don't need to create the object of the Module to call functions inside it. Here is some sample code:
vb.net Code:
' Module code
Module Module1
Public Function GetRandomNumber( _
ByVal minValue As Integer, _
ByVal maxValue As Integer _
) As Integer
Dim RandomClass As New Random()
Return RandomClass.Next(minValue, maxValue)
End Function
End Module
vb.net Code:
' Form code
Public Class Form2
Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
MessageBox.Show(GetRandomNumber(10, 20).ToString)
End Sub
End Class