Results 1 to 13 of 13

Thread: [RESOLVED][2008]declaring global variables

Threaded View

  1. #13

    Thread Starter
    Lively Member
    Join Date
    Apr 2008
    Posts
    74

    Re: [2008]declaring global variables

    Quote Originally Posted by dbasnett
    ...
    Thanx, thats exactly what i wanted to know. & to summarize all this:

    Code:
        'to add module go Project -> add module
        'Form1.vb
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim var As String = "Bingo"
            Dim var2 As String = "Bingo2"
            Test(var, var2)
        End Sub
    
        'Module1.vb
        Public Sub Test(ByVal myVar As String, ByVal myVar2 As String)
            MessageBox.Show(myVar & Chr(13) & myVar2)
        End Sub
    & another more simple way of diong it:
    Code:
        'Form1.vb
        Public myVar As Integer
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            myVar = 1
            aModule()
    
            MsgBox(modVar)
        End Sub
    
        'Module1
        Public modVar As Integer
        Public Sub aModule()
            modVar = 2
            MsgBox(Form1.myVar)
        End Sub
    Last edited by goldenix; Apr 25th, 2008 at 12:18 AM.

    M.V.B. 2008 Express Edition

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width