.:: Jasa Membuat Aplikasi Website,Desktop,Android Order Now..!! | | Order Now..!! Jasa Membuat Project Arduino,Robotic,Print 3D ::.

Use the Module in VB NET

0 komentar


بِسْــــــــــــــــمِ اﷲِالرَّحْمَنِ اارَّحِيم
bismillaahirrahmaanirrahiim

السَّلاَمُ عَلَيْكُمْ وَرَحْمَةُ اللهِ وَبَرَكَاتُهُ
Assalamu'alaikum warahmatullahi wabarakatuh

Use the Module in VB NET

Is sometimes useful to have functions or variables available everywhere in a Visual Basic project. You could use a module to do so. It is not complicate. There is no class creation.  And you could easily use this technique in VBA or VB6 (Visual Basic Application, Visual Basic Enterprise VB6, �) Module could also be used to share information or objects between classes.
Start creating a project. I choose the Windows Forms Project. Here is a sample of form1.


''' <summary>
''' put a Timer without the Visual Basic form Designer
''' </summary>
''' <remarks></remarks>
Public Class Form1
    Private WithEvents oTimer As System.Windows.Forms.Timer

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        oTimer = New System.Windows.Forms.Timer
        oTimer.Interval = 1000
        oTimer.Enabled = True
        oTimer.Start()
        If oTimer Is Nothing Then
            MsgBox("oTimer is Nothing")
        End If

        Dim oForm2 As New Form2
        oForm2.Show()
    End Sub

    Private Sub timerTicks() Handles oTimer.Tick
        Me.Text = Date.Now
        Module1.sTime = Date.Now
    End Sub

End Class






Create a form2 :


Public Class Form2

    Private Sub Form2_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

    End Sub
    Private Sub updateme() Handles Me.MouseDown
        Me.Text = Module1.sTime
        Me.Refresh()
    End Sub
End Class


Now create Module.vb.

Module Module1
    Public sTime As String
End Module



Here is how my solution explorer looks like this.


Alright, my code is really stupid, I know! But I only wanted to show you something very interesting.
On form1, there is a timer running over and over. Every second, it displays the time.  In fact, is nothing more than a simple clock. But the clock saves the time in Module1.sTime
Now, imagine I have another called form2. That second form would like get the timer value but it can�t directly. There is no methods to give the information, the variable is private, no heritage, NOTHING!!!!

Is time to use the Module. The advantage is that Modules are �available everywhere� at any time the module variables, properties, methods are also accessible as long there are public. That is all. Just keep that in mind.


So run your code, when your hold down your mouse button over the form2, it reads the value inside Module1. You could pass any object from one class to another simply by using a module.

By the way, feel  free to change your code and make it suitable for you:



    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Dim oForm2 As Form2
        Try 'alway try to put code that might crash in a try-catch
            oTimer = New System.Windows.Forms.Timer
            With oTimer
                .Interval = 1000
                .Enabled = True
                .Start()
            End With
           If oTimer Is Nothing Then MsgBox("oTimer is Nothing")
            oForm2 = New Form2
            oForm2.Show()
        Catch ex As Exception
            MsgBox("ERRRRRROR !!!! " & vbCrLf & ex.Message) 'idiot! you made a error
        End Try
    End Sub





Buy the same edition I bought:

or visite my web site :





Update Contact :
No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email : Fajarudinsidik@gmail.com
NB :: Bila Sobat tertarik Ingin membuat software, membeli software, membeli source code, membeli hardware elektronika untuk kepentingan Perusahaan maupun Tugas Akhir (TA/SKRIPSI), Insyaallah Saya siap membantu, untuk Respon Cepat dapat menghubungi kami, melalui :

No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email: Fajarudinsidik@gmail.com


atau Kirimkan Private messanger melalui email dengan klik tombol order dibawah ini :

ٱلْحَمْدُ لِلَّهِ رَبِّ ٱلْعَٰلَمِين
Alhamdulilah hirobil alamin

وَ السَّلاَمُ عَلَيْكُمْ وَرَحْمَةُ اللهِ وَبَرَكَاتُهُ
wassalamualaikum warahmatullahi wabarakatuh


Artikel Use the Module in VB NET, Diterbitkan oleh scodeaplikasi pada Kamis, 01 November 2012. Semoga artikel ini dapat menambah wawasan Anda. Website ini dipost dari beberapa sumber, bisa cek disini sumber, Sobat diperbolehkan mengcopy paste / menyebar luaskan artikel ini, karena segala yang dipost di public adalah milik public. Bila Sobat tertarik Ingin membuat software, membeli software, membeli source code ,Dengan Cara menghubungi saya Ke Email: Fajarudinsidik@gmail.com, atau No Hp/WA : (fajar) : 085369237896, (puat) : 085267792168.

Tawk.to