Using The Same Name For Event And Method Of Class?

Aug 15, 2011

am writing a class that has the same name for events and method, but visual studion won't allow me

The event
public event Close()
the method
Public Sub Close()
End Sub

how can i do this, i don't want to use different names

View 3 Replies


ADVERTISEMENT

Modify .net's BackgroundWorker Class So That It Fires A Custom Event Upon Method Completion?

Nov 16, 2011

I have a BackgroundWorker in a vb.net program that is doing a lengthy data import routine. I want to modify its RunWorkerAsync method so that it fires a custom event on completion of the method. (So that a method in an automated process can respond to the event and resume its work). In a sense I want to 'extend' the RunWorkerAsync method to add an extra line of code--but I can't 'see' the code in the method (to just add the line raising the event) because BackgroundWorker is an MSDN class from Microsoft.The only solution that I can think of is to 'wrap' the background worker class in a wrapper that calls the .RunWorkerAsync method and then raises the event.

Public sub wrapperMethod()
myBackgroundWorker.RunWorkerAsync()
raise customEvent
end sub

Is there a design pattern that I might use? An easy way to address this with the .net language?

PS: Unfortunately, I'm automating some clanking legacy software and backgroundworker is used in many locations, so wrapping the backgroundworker will be a bit of work and may open bugs.

View 1 Replies

Strongly-typed Generic Method Invokes Its Argument's Base Class Method Instead Of A Shadowed Method In T?

Oct 19, 2010

Consider a MyForm class that contains a shadowed implementation of Show(). It also contains a CreateForm() method, which accepts an instance of the form and calls the shadowed sub:

[Code]....

View 3 Replies

Get The Name Of Parent Method/class/file Name Inside Other Method Call?

Feb 16, 2010

I will try to explain what I need.Let's say that I have a class like this:

Public Class Example1 Public Sub ToBeCalled()

[Code]...

View 5 Replies

Raise Event In One Class And Handle The Event In Another Class?

Dec 27, 2010

Is it possible to raise event in one class and handle the event in another class? If so, how?

View 6 Replies

Create A New Class That Inherits From The Base Form Class And Define A New() Method With Parameters?

Oct 1, 2008

I've been creating short test apps repeatedly to try to understand some of the concepts in VB.NET.For the most part it has been illuminating.I read Bucky's .NET knowlegebase tutorial on passing objects as parameters to newly created forms. He shows how to create a new class that inherits from the base form class and define a New() method with parameters Extending the concept I thought about doing the same thing with a form that was created at design-time (In this case Form2).

[Code]...

View 6 Replies

Call Method Base Class In Program Passing Sub Class Objects?

Apr 22, 2012

Base class has one field to hold numeric balance value. With 2 methods that accept arguments for adding and subtracting the new input calculating new balance. Sub class has four fields dates, transaction, memo and amount.I have a deposit form, and withdraw form. Each time one transaction is entered it creates an object with sub class fields, then adds to the account collection. My problem is not understanding how to call the deposit/withdraw method and pass the current transaction amount back to the base class to alculate the new balance. Does anyone have any links to information/tutorials on how to perform something like this? As you can see with my code I have tried various different approaches without any success.

[Code]...

View 5 Replies

.net - Suppress A Property Or Method From A Base-class In A Derived Class?

Apr 7, 2011

Supose a base class

Public Class airplane
Private var_num_seats As Integer
Private var_num_engines As Integer

[code]....

Obviously, I don't wish that the class Glider has the method "start_engines" neither the property "num_engines". Otherwise, other child classes may have. How can I supress these property and method in child class, not just ignoring (if I can)?

View 2 Replies

Converting String To Class And Dynamically Raising A Known Method Of That Class?

Oct 5, 2010

class

eg: dim classobj = xyz("CLASS_NAME") ' where classname is a valid class name
and dynamically raising a known method of that class on that newly created object or class reference.

[code].....

View 4 Replies

C# - Calling A Method In A FACTORY Class When Application Is Closed / Disposed Without Using Application's Dispose() Method

Mar 28, 2012

I am indifferent if you are a VB.NET or C# or other .NET developer. I have a FACTORY class like the following:

[Code]...

View 2 Replies

Hiding A Method From A VB Class In A Derived C# Class?

Apr 20, 2011

I'm writing a set of unit tests for a large, complex class called ImageEditor from a piece of legacy code, where image processing and GUI functionality isn't strictly divided. One of the methods in the class, BaseImageChanged, seems to be concerned entirely with how images get displayed and should be disabled in my unit tests to avoid unnecessary complexity. The test project is in C#, and the original code is in VB; my idea was to create a Decorator for the class in C# and then hide the method behind an empty one that does nothing. However, when I try running the unit test, the VB code keeps referencing the old BaseImageChanged method as though the replacement didn't exist. Here's what I'm doing:

(VB class)
Public Class ImageEditor
...

[code].....

View 4 Replies

Populate A List(Of Object) In A Class Method, Where The List Was Passed To The Method As A Parameter

Aug 13, 2011

I'm trying to code a class of RandomNumber. One of the class methods needs to populate a "List (Of RandomNumber)" ... which was passed as a parameter to the method ... with 10 random numbers between 1 and 50. DEAD SIMPLE :)

View 6 Replies

Any Event Built In The Class That Is Fired Automatically When A Class Is Deserialized And Ready To Be Used?

Nov 18, 2010

I have a class that is stored after serialization and compression.Is there any event built in the class that is fired automatically when a class is deserialized and ready to be used??

View 1 Replies

Assign A Value To A Class From A Method Within The Class

Feb 13, 2012

I know this is possible, and it is probably something simple that I am missing... I have a fairly complex class to handle deserialization of an XML file. I wish to place a [class].loadfile method within the class. It looks something like this: Serialization decoration left out for simplicity...

[Code]...

The Deserialization is working just fine (that's my own code), but assigning the object value to Me is not correct. What I want is for an instantiation of this class to have a LoadFile method (similar to the XML class LoadFile method) - but I cannot figure out how to set the value of the class from within the class.

View 3 Replies

Handle An Event Raised In Class Inside Own Class?

Apr 14, 2009

I have a "partial" class in VB.NET. Half of it is auto generated by a code generation tool. That half implements INotifyPropertyChanged, so any properties in that part of the partial class raise the PropertyChanged event.In my "custom" part of the class, I declare another property that depends on one of the properties in the auto-generated side. Therefore, when that auto-generated property changes, I also want to raise a PropertyChanged event on my custom property that depends on it.

If I go into the generated part of the class and raise the event there, that will get overwritten if I ever re-generate that part, so I don't want to do that. I would rather add an event handler in my side of the partial class that checks if the generated property changed, and if so, raise another event for my custom property.

[Code]...

I'm assuming it's because normally you'd use the WithEvents keyword to tell the compiler that you're subscribing to events from that object. I don't have a clue how to do this inside of the class that's actually raising the event, or if that's even possible.

View 1 Replies

Asp.net - Inherit Same Method For 2 Different Class?

Sep 22, 2010

How to simplify this, 2 method in class are identical.First class.

Public Class Gui
Inherits System.Web.UI.Page
Public Sub CreateStyleLink(ByVal StyleArray() As String)

[code].....

View 1 Replies

Expression Is Not A Method From Within A Class?

Jan 9, 2012

I am getting an error when trying to call a form from within a method:

Expression is not a method

My code structure looks like this:

Public Class frmMain
Class Server
Private Shared Sub StringMessageReceived()

[Code]....

How can I call the windows form within the class?

View 1 Replies

Inherit Same Method For 2 Different Class

Dec 19, 2010

How to simplify this, 2 method in class are identical.[code]

View 3 Replies

Make METHOD In A Class?

Apr 29, 2012

I want to make an accelerate method that adds 5 to the speed field each time it is called?

[Code]....

View 13 Replies

Save Method In A Class?

Jan 6, 2012

I have a save method under the save button and i need to put this method in a class of it's own and then call the save from another method which is in another class. the following is the code of the save button[code]...

View 10 Replies

.net - Route Event Using A Method Argument?

Nov 10, 2011

I just have a short question about adding an destination methode as variable argument into my calling methode.

I want to send a "TextChanged" event to a special textbox. But I want to have a "variable" in my methode to add the handler to the textbox. Because it is possible to change the textbox and then I can change the handler where the "Changed Events" should be routed to.

can you replace the questionmarks below??

Dim TextBox1 as TextBox
Dim TextBox2 as TextBox
Private Sub DoIt

[Code].....

View 1 Replies

C# - Raise An Event Once I Reach End Of Method?

Jul 1, 2010

How to raise combobox_SelectedIndexChanged(object sender, EventArgs e) programmatically? Lets say i have method called ClearFields(). I want to call the event before i hit the end of Clearfields() method.

View 4 Replies

Call Event (method) From Variable?

Mar 9, 2010

If I have a string that contains the name of a control is there a way to call that control's click event?

Dim a as string = "MyButton1"

Now I want to call MyButton1.Click Method or MyButton_Click Event using the contents of a.

View 7 Replies

Event Driven Tcp Listener Method?

Aug 23, 2011

I'm another newbie with VB (2010) so please bear with me. I am attempting to make a method that is event driven by data threads on the Ethernet port. Simply put, the method is to wait until a data thread from a "Control By Web" 5-input device sends an "information update" data packet to the application, with the application then processing the information. This application is on a private, well controlled network, with no access to the internet. I have a method that is working right now reading data packets when invoked with a timer (see code below) but I really need it to be event driven.

' this is added at the top of the class
Dim tcplistener As New TcpListener(IPAddress.Any, ip_port)
'this is added in the "form1_load" module

[code]....

View 1 Replies

Raise An Event Through Delegate Method In .net?

Sep 16, 2009

may i know how to implement a delegate method into my project> currently i am using the serial port polling method by using a timer to read from the serial port, but now i am changing the method to delegate part.i have the code for the delegate part updating to the text box control but how do i modify it to update the mainform with my program codes.

The part for the delegate code is here

'---Event handler for the DataReceived event---
Private Sub DataReceived( _
ByVal sender As Object, _
ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) _

[code]....

View 5 Replies

Add An Extra Method To An Existing Class?

Sep 24, 2010

Suppose that I want to implement another method for a class namely hasFiles for System.IO.Directory , How can I do that?

for example if I add <Extension()> _ tag before each function or Sub I can add a new function or method for each Control.

View 3 Replies

C# - Create A Generic Method In A Class?

Apr 28, 2010

I am really trying to follow the DRY principle. I have a sub that looks like this?

Private Sub DoSupplyModel
OutputLine("ITEM SUMMARIES")
Dim ItemSumms As New SupplyModel.ItemSummaries(_currentSupplyModel, _excelRows)
ItemSumms.FillRows()

[Code]...

View 4 Replies

C# - Invoke A Method On A Class Using Attributes?

May 29, 2012

I want to invoke a method on a class that i have a reference to. The method that I want to call has a custom attributes. Currently I can find this attributes and call the property of my class Attribute.

is there a way to invoke that method ?

PS/ The project is written in vbnet, but I think the solution is the same in c#.

View 1 Replies

Call A C# Class's Static Method ?

Oct 28, 2010

I have a C# dll and want to use it in VB.NET. I'm using C# 2008 Express and VB 2008 Express. I have added a reference in a VB project to the C# dll. When I create an instane of a class in the C# dll, it gives the following error messsage: "Type 'RF.RabinFingerprint' has no constructors". My C# dll code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;[code].......

View 3 Replies

Call A Method From The Base Class?

Jan 3, 2011

REF: http:[url].....The above reference is where I got the code below.This code adds buttons to Form1. When a button is clicked a messagebox appears stating what button was clicked. I want to have the ClickHandler fill a RichTextBox on Form1 (I added a RTB to Form1). My problem is I can't do a Dim xForm As New Form1 to fill the RTB from the ButtonArray Class. I can place my file's text in a MessageBox so I know the code I added is correct. I also tried placing a Property method on Form1 and using a Accessor to fill the RTB, however it also requires Dim xForm As New Form1. How can I get my data from files to the RichTextBox on Form1 from the ClickHandler in the ButtonArray Class? See ButtonArray Class Below.

Imports System.IO

Imports System.Text

Imports System.Collections.CollectionBase[code].....

View 5 Replies







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