Lets say I have one button on a form, and write the code for what happens when I push the button in a modul, instead of in the button. And in the button I only refer to the modul.
Because when I make a program the public class form gets pritty full of code.
Is that possible

Using modules for storing code
nikos_22
Yeah, that worked perfectly.
But now I have encountered a new proble, in my Form1.vb I have
Dim
cdgs As ULongAnd when I make a function thats using that variable, I get an error ofcourse.
How can I make my module read and write to exactly that variable
Form1.cdgs = 1
' that didnt workFei-tian
You are beginning to discover why putting all your procedures in a module is not such a good idea. In order to make it work you will have to either move your variables to the module, in which case if you want to access them from your forms they will have to be public. Or you make them public in the forms and then access them with Form1.variable as you have tried.
Either way you are losing all the benefits of encapsulation and on balance you are better off keeping your code with the data in the class where it belongs.
Jack Spade
Public Function Test()
MessageBox.show("This Works")
End Function
the call out the function in your form:
(this is simply an example)
sub Button1_click()
Test()
End Sub
yahu_Hugh
Douglas Penna
Hi,
Try putting>>
Public cdgs As Integer
in your module code.
or just write>>
cdgs=1
Regards,
S_DS
P.S. You could do this with a CLASS too or a STRUCTURE but that would probably be too long winded.
joeydj
But problems appear when I want to "Call" the function, how do I do that
Private Function testing() As Boolean
MsgBox(
" Calling a function works! ") End Functionpmail
I get an error "Lib" expected
declare
sub testing as public