none
connect Form to module through button

    Question

  • hello,

    I've created a windows Form with vb.net and a module within the form how can I show the module with button.click?

    Thanks 

    Thursday, March 30, 2017 3:27 PM

All replies

  • Not sure what you want so here is something that may prompt you to divulge more.

    Public Class Form1
        Private Sub Button1_Click(sender As Object, e As EventArgs) _
            Handles Button1.Click
    
            Payne("was here")
    
        End Sub
    End Class
    Module Karen
        Public Sub Payne(someValue As String)
            MessageBox.Show($"Karen {someValue}")
        End Sub
    End Module

    Personally I would not recommending the use of code modules other than for language extension methods. Here I'm using a class.

    Public Class Form1
        Private Sub Button1_Click(sender As Object, e As EventArgs) _
            Handles Button1.Click
    
            Dim kp As New Karen
            kp.Payne("was here")
    
        End Sub
    End Class
    Class Karen
        Public Sub Payne(someValue As String)
            MessageBox.Show($"Karen {someValue}")
        End Sub
    End Class
    
    The proper way would be to place the Karen class into a separate class file and make it public or friend depending on how may use the class.

     

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Thursday, March 30, 2017 6:59 PM
    Moderator