Handle Events From The Main Form In A Separate Class Or Module?

Feb 24, 2012

I've been searching for the answer for a while but can't find it yet. Basically so far I have a simple VB.Net form with one button.I would like to make a class or module that can handle events from the main form. This is my code so far but it doesn't seem to work.

View 6 Replies


ADVERTISEMENT

Handle Events And Notifications From Multiple Sources To A Main Form In .net?

Sep 23, 2011

I have a vb.net application in which there is a main form. There are around 10 classes each having their own functionalities like tcpactions, fileactions, serialport actions etc. The user interacts with the main form and does certain actions which will invoke the methods in these classes. Now I have a notifications textarea in the mainform and i want to show the current action being performed in those classes and their results in the notifications area.

for example when a user clicks a "Start Process" Button in the form i invoke the method "launchprocess" in a class "ProcessActions". Now this method tries to launch about 7 different process and after launching it sends notification such as "process 1 launched" or if it fails it sends notifications such as "process 1 launch failed".

I currently use event handlers and use them to show notifications but with the amount of events i have to handle it is getting cumbersome and i might have to add even more classes in the future. So is there a better way of handling notifications from other classes.

View 1 Replies

Raise Events From Class Library To Form Using Module?

Jan 25, 2010

i've a app that starts from a sub in a module, do a few things, and then load the form.

But it doesn't work :/

Here we execute dBase.AddTemporalFilepath

module.vb
Public dBase As New Core.clsDatabase
Public Sub Main()
FurBase.Directory = My.Application.Info.DirectoryPath

[Code].....

View 1 Replies

VS 2005 Class Api Needs To Get A Handle On Form Elements In The Main Worker Thread

Sep 4, 2009

I have a standard windows application called winap. I have a com component which acts as an api to the winap. I have a class in winap call classapi which has all the methods that the api calls and all works well. The problem is that one of the methods in my class api needs to get a handle on form elements in the main worker thread. Whenever I try to access an existing form I keep getting null because the for exists in the main worker thread and my api call is in a seperate thread.

[Code]...

View 5 Replies

Set And Get A Value From A Class Property Within The Main Event Of A Module?

Jul 8, 2011

the project uses a submain as startup object which is located in a module, thy so the application will be started in tray. Within the main() event i need to deserialize a xml file and with it set the properties of a class and then set what the application will do.The problem is, after I deserialize it and put set the property values I try to get them in the same event(main) but when it gets the value it returns as nothing(if string) or 0(if integer) but in the debugging i saw it setting the values.Is there a way to do that, within the main() event of a module to set the properties of a class and then get them without being nothing/0 ?

View 6 Replies

Define A Main Method In A Class Versus A Module?

Jul 12, 2011

I was just practicing some coding and noticed that I was able to use class instead of Module in VB .NET. So I replaced my module to class and I got this error message:No accessible 'Main' method with an appropriate signature was found in 'practicevb'.practicevb

I made sure that the startup object was set correctly in Properties > Application > Startup Objects.The error message disappears if I change it back to Module but I would like to keep it class since the other parts of my code I changed to class and didn't return and error messages.

Class Atic
Sub Main()
Console.WriteLine("Hello, this proram will calcaulate the quadratic forumla ax^2 + bx + c")
Dim Quads As New Quads

[code]....

View 4 Replies

Forms :: Set And Get A Value From A Class Property Within The Main Event Of A Module?

Jul 8, 2011

the project uses a submain as startup object which is located in a module, thy so the application will be started in tray. Within the main() event i need to deserialize a xml file and with it set the properties of a class and then set what the application will do.The problem is, after I deserialize it and put set the property values I try to get them in the same event(main) but when it gets the value it returns as nothing(if string) or 0(if integer) but in the debugging i saw it setting the values. Is there a way to do that, within the main() event of a module to set the properties of a class and then get them without being nothing/0 ?

View 3 Replies

VS 2008 - Sub Main In Module Versus Shared Class

Feb 17, 2010

In VB6 I always wrote my apps using Sub Main as the starting point. I see in .NET I'm able to wrap it in a shared class (see [URL] for example). However, the downside is that I can't declare any class-level variables, because of course the class is never instantiated. Being shared, it limits what the code can do. So, any benefit to use a shared class and shared sub main which I'm missing here.

Otherwise it seems using a module (as in VB6) provides a lot more flexibility. Of course, I should also ask if "Application Framework" is really the way to go for real-world apps, or if it's only there for beginners and real-world coders turn it off and use Sub Main instead? If so, how are the events "UnhandledException" and "NetworkAvailabilityChanged" done if App Framework is turned off?

View 28 Replies

Handle Events In Another Class

Sep 2, 2011

I'm trying to move some code into some class files to clean up my code. One area I'm having trouble with is reporting progress for events between the object performing the task and a progress bar. I guess the event functions have to be placed in the new class but they also need to update the progress bar on the calling form? Can the classobject return updates in place of the event handlers?

[Code]...

View 2 Replies

Vb6 Handle .net Com Class Events?

Nov 13, 2009

i have the ComClassSearchCustomers class and interface IComClassSearchCustomersat .net which used to create a tlb file. The class raise an event inside new. After that i have a vb6 form Form1 which catch the event , but it never see the event.

[Code]...

View 3 Replies

Rising Events From Class Library Called From Module

Jan 26, 2010

I've an app that starts to work from a module wich should load a form an do other things with a class library who raise an event an the form shoud cath it.The problem is that applicarion.run(frmMain) displays the form in the same thread the the code stops work while the form is open. And I need that the app works in this way because the user need to send files to the app using args and this avoid that the app init another instance of it (in other code) and update the form with the info when the event is raised.[code]

View 9 Replies

C# - Handle Events Of Members From Another Class / Instance?

Jul 14, 2010

I am attempting to share a sub menu among several different parts of an application so that it is consistent (not wanting to copy/paste.) I thought it would be simple. I am doing something like this:

[Code]...

View 3 Replies

Handle Events Of A Control In A Class File?

Feb 22, 2010

if I wanted the button onclick event in a different class how would I declare it?

when I refer back to the form it says I need to declare with events..

Private Sub btnAddToLaneFilter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Dispatch.btnAddToLaneFilter.Click
If Me.txtCriteria.Text = "" Then

[Code]....

View 1 Replies

VS 2008 Rising Events From Class Library Called From Module

Jan 26, 2010

I've an app that starts to work from a module wich should load a form an do other things with a class library who raise an event an the form shoud cath it. The problem is that applicarion.run(frmMain) displays the form in the same thread the the code stops work while the form is open. And I need that the app works in this way because the user need to send files to the app using args and this avoid that the app init another instance of it (in other code) and update the form with the info when the event is raised.

[Code]....

View 5 Replies

Load The Main Form Of A WPF So That A Separate Thread Goes And Gets Data From The Database While The Form Is In An Apartmentstate?

May 15, 2012

How do i load the Main form of a WPF so that a seperate thread goes and gets data from the database while the form is in an apartmentstate? (drag-able / movable) I Know this is possible with opening a new window from your main form like this :

Private Sub openOrderWindow()
Dim OrderWindow As Orders = New Orders
OrderWindow.ShowDialog()
End Sub

[code]....

I've tried putting MyBase.ShowDialog() and .Show() and .9000+ other things The only benefit I've got out of using a seperate thread to load from the databse is i can see the screen right away (as oppose to it being a transparent box until it loads) but i cannot move it around or minimize it?is there any way to make it Movable while it loads?

View 1 Replies

C# - Write All The Control Events In A Separate Class File In Different Layer Rather Than In Code-behind Of Webpage?

Nov 16, 2011

Can we write all the control events in a seperate class file in different layer rather than in code-behind of web-page ?

View 1 Replies

One Routine To Handle Multiple Events In Arraylist Class Object

Oct 17, 2011

I want to use One routine to handle multiple events & i want to give the list class object to the routine handle clause in vb.net. Is it possible? I have 100 buttons on my web page & i want to handle click event of each button. I have same coding on each button but the only difference is that, which button is calling the event handling routine. So i want to make one sub routine for handling event of all my buttons.

I can solve this by writing each button name in the handles clause like - Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ImgRCP_26.Click, ImgRCP_27.Click,. But it is so lengthy procedure. So that why i want to handle my button in the arraylist. How to do this?

View 1 Replies

Forms :: Access Main Form From Second Thread Running In A Module?

Jun 22, 2010

I was a vb6 user, done a few projects only with forums Now i am moving to vb.net(vb2010) and i have some trouble.Lets say we have a form(form1), a module(mod1) and a textbox on the form1.

i want to start a Sub (DoWork) in the module but in a new thread.

Dim Thread1 As System.Threading.Thread
Thread1 = New Threading.Thread(AddressOf mod1.DoWork)
Thread1.Start()

The DoWork sub does some stuff and when it's finished i want to change the text of a textbox1 in the main form and start another sub (DoWork2) on the main form under the main thread not the one DoWork is running under.

Plese do not refer me to another post that mighe give me a part answer, try to explain to me what i have to do and why.

View 3 Replies

Make A Module To Store All My Sub's For Populating A TreeView On My Main Form?

Jan 24, 2010

I decided to make a module to store all my Sub's for populating a TreeView on my main form. My question is, how do I make the Module.vb where I'm storing these Subs recognize the TreeView on my main form? I'm going to create subs such as this:

Public Sub Populatetest()
Dim _GeneralNode1 As TreeNode = TreeView1.Nodes.Add("Test")
End Sub

View 4 Replies

How To Capture Form Events From A Separate Running Process

Mar 21, 2011

I'm trying to automate a product that provides no such automation capability.I've take a cursory look at loading the app in a separate AppDomain, and also, through reflection, executing the Program.Main() to get the app running. I also tried getting the windowhandle from a separately created Process object (which I've learned will not work).If I have a reference to their assembly added to my project so I can reference an instance of "TheirProduct.FormMain", what, if it's possible, is the best way to go about capturing events from that form? What I need to do is to be able to capture a couple events, and perform a few Button.PerformClick() against the form.

View 1 Replies

VS 2010 Form Unable To Handle Other Events?

Apr 7, 2011

I'm trying to use a asynchronous UDP-Port to recieve data on a form.I manage to receive one message at a time(for each click of btnReadData), however if I do this receive in a loop (in order to continously receive new messages), my form seems to be locked.What am I doing wrong?

Public Class FPR2DIS
Delegate Sub dDataReceived(ByVal Data As String)
Dim UDPWorker As New Worker

[code].....

View 3 Replies

Pass A Handle In A .NET Form To C For It To Draw On/get Click Events?

Jul 20, 2009

I am trying to put a new face on an old C program. The C program is, of course, unmanaged code, designed smartly to separate the number crunching and the interface, and the interface I'm trying to replace is X windowing. The graphics part is where it gets a little hairy, because the C is going to need to continue to draw in my new interface, based on the data the program produces. Even if I want to duplicate that data in .NET so that the .NET side can handle all of the drawing, the fact remains I'm going to need to operate on the graphics window in some fashion from C.

I gather that handles have a lot to do with the bare Win32 graphic operations. Is such a similar handle provided to, say, a PictureBox element in .NET? And if so, is it the kind of handle I can use in the unmanaged code without an issue?

I have tried and tried and tried to google for the solution for weeks now, and all I come up with are either C++ solutions (using object-oriented GDI+) or some sort of extension to the C language.

Alternatively, is there a way I can have .NET create a handle specifically for this purpose of having C draw it?

To sum it up, I am using Visual Basic .NET 2008 and a C DLL (also compiled in VS2008), so far in the little testing I've done, I've been able to marshal complex structures to and fro, but I am not sure how exactly I'd let C do any drawing on the .NET form, if that was even possible.

View 2 Replies

Access A Progressbar In Form From A Separate Class?

Oct 18, 2009

I need to be able to access a progressbar in my form from a separate class.

I tried


Dim Prog as Progressbar
Public Property Pg()
Get

[Code].....

I need to be able to access a control from a separate thread and return to the thread again.

Edit: Its just an example I gave prog a value of the object from the form and the invoke required is put in a sub so thats not my problem.

View 3 Replies

Delete A Module , Class / Form?

May 9, 2009

I wonder how do I delete a Module or Class or a Form.[code]...

View 10 Replies

How To Call A Class From A Main Form

Mar 5, 2010

How would you call a class from a main form? In VB6 you would call a module by just simply calling the module name.

View 2 Replies

Class Not Registered While Loading Main Form

Apr 1, 2009

We have a Dell laptop used to run an in-house VB.NET program. It got a virus. We had to wipe the hard drive and reinstall Windows from scratch. We use Windows XP Pro, which is what was installed on it before. But now our VB program won't run. After trying and despairing of getting remote debugging to work, I actually installed Visual Studio 2005 on the machine, just long enough to get information about what was making the program fail. And the failure was most peculiar. It isn't in our code. It's in the VB setup code that loads the main form. And it says, "Error loading form: class not registered."The gory details are given below. Now here's the strange thing. Not every VB.net program fails on this computer. And the program that fails, fails only on this computer; it has run successfully on several other Windows XP systems with .NET Framework 2.0 installed.[code]

View 3 Replies

VS 2008 Can Call A Class From Main Form

Dec 14, 2011

As of the moment I have 24 buttons that are keys to a piano.24 of the button codes have a call method that calls the note to be played.24 of the private subs that are called have an .wav audio playback command within them. I was hoping I could move the .wav private subs into a separate class, and just call them from my main form, therefore cleaning up the lines of code I have at the moment. [code]That example only counts for one Button "The Key of C", and the audio file that is called with it. Multiply that by 24 and you get a big mess of repetitive junk.Can I move the audio subs into a class and call them from my main form?

View 16 Replies

VS 2008 - Class Module Gets Data Entry From Form

Dec 16, 2010

I've been coding a Windows applicaton for the past seven months but there aren't a lot of "windows" in the application so I have a question on getting and returning data from forms. I display a form and the user makes a listbox selection then presses Ok. Normally I can proceed from there (in a class module) with values from the config file, but sometimes his selection will require me to ask for more information. So I want the class to display a form, pass control to it, then when the user hits OK on this form, return to the class. What is happening is the class continues with all its inline code and function calls and doesn't show the form until the end of its current function.

Dim flClientInputFile As New CFile
Dim flPreparedOutputFile As New CFile
Dim lRecordCount As Long
Dim sProcessing As String
Dim sTest As String
Dim frmAbc As New frmAbc
frmAbc.Show()
frmAbc.Activate()
x()

When I run and step through this code, I find I'm in x() before I even saw the form. x() needs the data the user has entered on frmAbc in order to continue.

View 2 Replies

Accessing Function In Alother Class From The Main Form?

Feb 12, 2011

I have a new solution with 5 projects inside. a data access layer, database, 2 class libraries, and the main form. These are all components that I had worked on to get to this point of combining into 1 solution. Now what I have run into is I can not the actual functions in the class libraries. I can get to the class level, but that is it. ere is a sample line of code I need to get working. Once I get this one line, the rest will be obvious: Temperature is on the main form. get for options is "Equals, GetHashCode, GetType", etc... Before this I had bult, compiled, and referenced these classes separately, and it worked fine. I know this is going to be an easy answer, I'm just not seeing it for some reason.

View 15 Replies

Make A Shared Function For Form Load In A Separate Class File?

Jan 9, 2012

i would like to have a shared function in a separate class file to address the form location . but i dont know how can i get this to work. if i use this below code in my form its working . but i cannot move this to a class file.

Shared Sub Formlocation()
Me.StartPosition = FormStartPosition.Manual
Me.Location = Screen.GetWorkingArea(Me).Location
End Sub

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved