CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2000
    Posts
    45

    General Declarations

    what is the declarations for? i dont get it, i have only read one vb book.


  2. #2
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: General Declarations

    The general declaration is used to declare variables who must be accessible from within the form/module it is in(DIM), or withing the entire project(PUBLIC).
    Like if you had this code:

    'public declarations
    Dim s as Integer

    public sub Command1_Click()
    'button 1 is pressed
    t = t + 1
    msgbox t
    End Sub

    public sub Command2_Click()
    'button 2 is pressed
    s = s + 1
    msgbox s
    End Sub



    This would result in that when you press button 1, 1 is added to T, but because T isn't declared, it's value is cleared whenever the program leaves the sub, in this case after the messagebox. This results in t always being 1 when button 1 is clicked.
    However, pressing button 2 will result in 1 being added to s. The value of S will remain the same when the program exits the sub. So when it enters the sub for a second time, it's value will be 2.

    Tom Cannaerts
    [email protected]

    The best way to escape a problem, is to solve it.
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

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

Featured