Override A Public Shared Method In Derived Class?

Oct 8, 2010

Can we override a Public Shared method in derived class? If not why?

View 2 Replies


ADVERTISEMENT

.net - Can A Generic Version Of A Derived Class Override A Base Method Using The Generic Type

Apr 13, 2012

Consider:

Public MustInherit Class Column
Public ReadOnly Property ReturnSomethingUseful() As Object
Get
'return something useful

[code]....

But this gives the following error:

Public Overrides Function ParseValue(sValue As String) As Boolean'
cannot override 'Public Overridable Function ParseValue(sValue As String) As Object'
because they differ by their return types.

I accept that you can't do this, but I'd like to be able to preserve the semantics of what I'm. trying to do, which is to have an untyped version that deals with Object, but a typed version in derived classes that knows about the specific type T.

View 2 Replies

Use Derived Class Shared Variables In Shared Methods Of Base Class?

Jun 4, 2010

I am trying to add shared members in derived classes and use that values in base classes...

I have base

class DBLayer
public shared function GetDetail(byval UIN as integer)
dim StrSql = string.format("select * from {0} where uin = {1}", tablename, uin)
end function
end class

[Code]..

currently there is error using the tablename variable of derived class in base class but i want to use it i dun know other techniques if other solutions are better then u can post it or u can say how can i make it work? confused...

View 2 Replies

.net - Why Can't Call Private Shared Methods From A Public Shared Method

Aug 25, 2011

I have a class like this:

[Code]...

It works, when I make getBar methods public, but I don't want to expose these unneccessarily. Why I can't call private shared methods from a public one in the same class is over my head. I'm using .net framework 4.0 in a web application.

View 1 Replies

Derived Class Shared Methods?

Nov 3, 2010

I have a function that 2 derived classes use, but the third doesn't, would it make sense to just leave it in the base class, even though one of the 3 derived classes doesn't use it?The only way I could think of disallowing the third class is to basically create an intermediate class that is derived of the base, then the 2 that use the common function are derived off the second class.

Is it possible to prevent the 3rd class from using the function, while letting the two that are supposed to use it, use it?Does that just seem to go overboard, I mean as long as I don't "try" to call the function from the 3rd class, it shouldn't be a problem, I just was interested if there was a way to prevent it all together without a lot of hassle.

View 2 Replies

Asp.net - Access A Module Or A Public Class With Public Shared Members From Inline Vb Code <% .. %>?

Feb 10, 2011

I can access a module from code behind but not from the aspx page in inline VB code <% ... %>.

View 2 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

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

Hide A Derived Method Of Base Class?

Sep 10, 2009

I would like to inherit from the Data.DataColumn in order to produce a DataTextColumn. That means that in the derived class, I dont want to see the non-applicable AutoIncrement property and the like - all I want to see are properties that apply to string types.[code]...

View 5 Replies

Method To "override" Shared Members In Child Classes

Mar 5, 2010

At the moment I'm trying to create a kind of model in vb.net which can be used to create/fetch database entrys.

I created a main class Model with a shared function to fetch the datasets, e.g. Model.find(). Now I'd like to create Classes which inherit the main Model-Class, e.g. a separate one for users: UserModel.find() => "SELECT * FROM users".

What I need now is to find a way to tell the Class which table it should use. I thought about an abstract String "table" which is a constant in each "child-model", but how could this be implemented as it's not possible to override shared members?

Edit: Maybe this will make it a little clearer what I mean:

Public Class Model
Public Shared _controller As Controller
Public Shared table As String

[Code].....

So I want a shared method which finds all database entries and gives back an array of instances of its own type, e.g. Model(). That's why I wanted to keep the find-method shared and not bound to an instance.

View 4 Replies

Accessing A Public Shared Variable From A Different Class?

Jan 10, 2012

I currently have two forms, and I need to share the value of a variable in one of them.

I declared the variable to be 'Public Shared', and assigned a value to it. However,

when I inspect the value it appears as 'Nothing'. Here is the snippet:

Public Class A
Public Shared sVar As String = Nothing
Private Sub A_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

[Code]....

View 4 Replies

[2005] SyncLock And Multithreading - Public Class Utilities With A Many Shared Functions

Feb 11, 2009

I am trying to get a handle on SyncLock and multithreading, but I am having some trouble wrapping my head around exactly how it should be implemented. I have a Public Class Utilities with a many Shared Functions. I want to make sure that each function can only be executed when there are no other concurrent calls to the same function. So If I have 2 functions, A and B in a Public Class Utilities, what is the syntax so that a function "locks" while it is being executed, preventing any subsequent calls until the "locking" thread has completed?

CODE

Public Class Utilities

Public Shared Function A (ByRef i As Integer) As Integer

[CODE].............................

I know I need to wrap the statements of execution in a SyncLock block, but I am unsure of the scope of the parameter used with SyncLock...is it private to the function, class, etc? Can the same object be used to lock both functions if they are independent?

View 36 Replies

VB - How To Use Dll - Project Class Library, Named It MyFirstDll And Made A Public Shared Sub HelloDll

Apr 21, 2012

I am just testing how to use dll and after googling a lot, I made it work partially...Created new project Class Library, named it myFirstDll and made a Public Shared Sub helloDll to do something. Now since this is my first time, the dll is simply showing the input in a msgbox:

Public Shared Sub helloDll(ByVal msg As String)

If msg <> "" Then
MsgBox(msg, MsgBoxStyle.OkOnly, "WE HAVE SOME MSG")
Else
MsgBox(msg, MsgBoxStyle.OkOnly, "NO MSG")
End If

End Sub

After building the dll-file, I started a new project using normal windows forms, named it "useMyDll", I clicked Project -> Add Reference, and added my dll. The program file that I made needed a textbox and a button for using the dll:

Private Sub useDllButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles useDllButton1.Click
Dim msg As String = Nothing
msg = TextBox1.Text
myFirstDll.myFirstDLL.helloDll(msg) 'this will be in msgbox in dll-file
End Sub

And when running this I could write something in the textbox and a msgbox with that input would pop up. Really happy with that. My first attempt to make a dll and use it was very successful. Then I thought, what about running the dll from rundll32.exe? It would be handy to make a dll that could be run without my exe. After googling a long time, I tried to add a new button:

Private Sub useDllButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles useDllButton2.Click
'Now let us see if we can open it using rundll32.exe ?
Dim msg As String = Nothing
msg = TextBox1.Text

[CODE]...

Now the first button still works just fine, but the second button gives some error (translated to english would be) like "missing entry: helloDll" I also tried to open with command prompt, same result.

After googling again I read one place that you can't run a visual basic dll with rundll32.exe, so is this true? Or is there some way of doing it? I read one place that it works if you make the dll be "COM-Visible", but I don't really understand how to or what it means. I tried to open properties, clicked Assembly Information, and "Make assembly COM-Visible", but this doesn't change anything. Then I read somewhere that it has to be in a module to work. Could it be that I need to rewrite some codes and it would work, or would I have to start learning c++ in order to accomplish this?

View 13 Replies

Get Type Of Derived Generic List Class From List Item Method?

Mar 23, 2011

Public Class notifierMain
Public Class Contacts
Inherits List(Of row)
Public Sub New()

[code]....

When I debug this winforms application I get curType = "notifier.notifierMain+Contacts+row" I want to the Validate function to know it is in MyContacts. How do I do this?

View 3 Replies

Call A Shared Method In A Loaded Dll Using Class Name?

May 8, 2012

[code]...

Dim ass as Assembly = Assembly.LoadFile("sample.dll")

Now, I want to call the shared method using the class name.

View 1 Replies

Class, Method, Namespace, Private Vs Public?

Feb 16, 2012

what websites, books or courses you guys suggest to use so I learn the fundamentals of programming. What is a class, method, namespace, private vs public. That leads me into .Net programming. A lot of intro to programming use java or C++ as the platform but I want to find one with VB.net or maybe C# if.

View 6 Replies

Overload Method To Existing Public Class?

May 8, 2009

I have written a method to replace multiple characters in a string. Is it possible to overload my own method to the existing method "Replace" in the String namespace?

Function Replace(ByVal inValue As String, ByVal ParamArray replacechars() As String) As String
For i As Integer = 0 To UBound(replacechars) Step 2

[Code].....

As you can see it have a different signature from the public method so I think it would be nice to have my method overloading the existing method

I can live with it if it isn't possible. See it as a "nice to have"

View 2 Replies

Access A Class Variable Inside Shared Method (JSON)

Jun 20, 2012

Inside my .aspx I have some JSON code that looks like this:

[Code]....

Basically what I'm doing is pulling text from two labels on one page, and sending them to another page by calling the "doIt" function which looks like this:

[Code]....

Just so I'm clear, the "doIt" function and the JSON call are on two separate web forms. My problem is that with the "doIt" function being Shared, I can't access any global variables of the class. And if I remove the Shared, my JSON doesn't execute.

View 1 Replies

Asp.net - Public Shared Variable Shared Between Users?

Mar 30, 2012

I've taken over the maintenance of the website (ASP.NET VB) and on one particular page I noticed the below code

Inherits System.Web.UI.Page
Public Shared UserNumber As String
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init

[Code]....

My question is whether the variable UserNumber can be accessed or changed by any other user than the current one?

View 2 Replies

Override 'Equals' In A Structure With All Shared Members?

Dec 5, 2011

I have a structure written in vb.net with all shared members. I need to override 'Equals', '==' and '!=' to avoid a warning.

View 4 Replies

Shared Method Not Calling Shared Constructor

Aug 12, 2009

Given in the following language specification, for me at least, calling Db.Foobar() [In the following code] does not indeed call off to the Shared Constructors of the base classes. I am curious as to a) is this my own fault for doing something wrong or b) is this an error in the language specification[code]...

View 2 Replies

Access The Base Class Inside A Derived Class?

Oct 22, 2010

How do I access the base class inside a derived class?

View 1 Replies

Declare A Public Param For Public Class Form1?

Apr 7, 2011

Imports System
Imports System.Threading
Imports System.ComponentModel[code]....

how to declare "smsport" on class smscomms as public so that it can be access in class form1 or button1_click event.

View 5 Replies

Public Shared Variable Ref?

Jun 29, 2011

I have an arraylist in a user form (Mainform) that I would like to be able to share among multiple forms and edit the contents. Using the Public Shared method I have been able to view and even edit the arraylist, but it does not seem to be changing it back on the main form. I can give more detail if needed.

View 9 Replies

Copying A Class Into A Derived Class?

Oct 19, 2010

I have two classes, one derived from another.

Private Class clsVehicles
Public Make As String
Public Model As String

[Code]....

View 11 Replies

.net - RemoveHandlers In The Derived Class

Mar 19, 2010

I use to set WithEvents variables to Nothing in Destuctor, because this will "Remove" all the Handlers associated with Handles keyword. Will this have the same effect for derivated classes?

[Code]...

View 1 Replies

Set The Values In The Derived Class?

Apr 26, 2009

I have a base class where amongst other code I have declared 2 properties. In my derived class, I get data from the DB and assign the results to the base class properties. This is so when I go back to the base class code, I can access the property values. It allows me to set the values in the derived class but once I go back to the Base class, the values don't exist.

[Code]...

View 8 Replies

Public Shared Function Continued?

Aug 6, 2009

I made the changes from this:

[code]...

to this:(the 'End Function' says "Function 'GetFolderPath' doesn't return a value on all code paths. A null reference exception could occur at run time when the result is used."

[code]...

View 4 Replies

Public Shared MyVariable As String?

Jun 21, 2011

Say I have an ASP solution with a Globals.vb file. Inside that file, I have this: Public Shared MyVariable As String Now say I publish this solution and make it available to Bob and Cindy.If Cindy sets (through the interface) MyVariable to 5, would Bob be able to read it? I hope not, I'm hoping this variable would be user-specific.

View 2 Replies

Copy DataTable Derived From My Own Class?

Jun 18, 2008

I have a derived DataTable[code]...

Overload resolution failed because no accessible LoadDataRow' can be called with these arguments.

View 15 Replies







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