|
-
Jul 3rd, 2003, 05:19 PM
#1
Addicted Member
Originally posted by AlvaroF1
You are right. This example is only to show what is not working.
Do you have other idea to control form's controls within a module?
Thanks.
In .net, there is no real need to use modules. They are only supported to help vb6 programmers, who are used to using them. Behind the scenes, .net creates a class which is globally imported throughout the project, and all of the properties, methods become shared.
What is actually wrong with your sample however, is that Form1 loads intially, end when you call Test(), you create another instance of Form1, which you never display.
Try the following and you will see what I mean:
VB Code:
Module Module1
Public Sub Test()
Dim frm As New Form1
frm.Show()
If frm.Button2.Enabled = False Then
frm.Button2.Enabled = True
Else
frm.Button2.Enabled = False
End If
End Sub
End Module
But why would you want to control a form's controls inside a module? I think you should encapsulate the code relating to a particular form whithin the form itself. If you had many forms with same functionality then this contolling the forms common controls within another class (or even a module if you like), but you would need to use the existing instance of each form to control it rather than creating a new instance.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|