Click to See Complete Forum and Search --> : Please help with using forms and modules


masha
March 30th, 2004, 11:43 AM
Hi,
I am new to VB.Net and OOP and am lost with using forms and modules.
I have a form with a button and I want to run some code from a module called simulate when the user clicks this button.
So, I wrote Simulate.Main() in the button's click event (simulate module should start from its main procedure), but somehow when I click the button it never gets to this module, if I click pause to debug, it shows me a green arrow and highlights the line Public Class frmSimulation green. What might be the problem?
Is it the way I call the code or is something wrong with the form?
I would appreciate any help,
Masha

Craig Gemmill
March 30th, 2004, 04:41 PM
You probably want to zip this one and post it... I'm not sure there is much we can do without seeing the whole project.

gasperCasper
March 31st, 2004, 01:22 PM
The way I do this is given below:

Module Simulate
'instead of naming the procedure/sub as Main name is a simMain
public function simMain
'write all your code
end function
End Module

--------
In your button_click event now call the simMain

Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click
simMain() 'Note this is defined as PUBLIC func.
'also note that Simulate is a part of this solution
End Sub