Handle Shared Members When Dealing With Interfaces?

Sep 30, 2011

So I did tons and tons of work trying to make an interface for a common set of classes. The idea was to make an interface that each class could use within the set, but ultimately each class is different. Turns out interfaces do not like shared members. What I tried:

Public Interface ISomeInterface
Shared Property Meta() as Object
End Interface
Public Class A
Implements ISomeInterface

[Code]...

Obviously, had I done my homework on this, I would have known that shared members can't be use in interfaces. Should I just leave the individual classes completely responsible for handling its shared members? Is there another way to keep coupling down to a minimum with shared members? Theres about 20 something or so classes that will implement a single interface.

View 2 Replies


ADVERTISEMENT

Initializers On Strcture Members Are Only Valid For Shared Members And Constants?

Jan 5, 2010

ok this is annoying, i've got a structure RInteger.

Private VAR_Value As Integer
Private VAR_Max As Integer
Private VAR_Min As Integer

[code]......

View 5 Replies

Inherited Members In Interfaces?

Apr 21, 2010

When I pass an an object 'MyObject' which implements 'IMyInterface' to a method parameter declared as IMyInterface, I understand that this method parameter 'sees MyObject through the eyes of its interface'.

View 2 Replies

Implementing Interfaces On Classes That Already Have The Interface Members Defined?

Jun 25, 2010

So say I define some interface, and that interface has members that need to be implemented under some idea, and I then implement this interface on a class that already has those members defined. How do I NOT receive errors about having to implement said members despite them already being implemented (because I didn't type the oh so ridiculous 'implements IMyInterface.foo').

For example say I have an interface that defines the event KeyPress, and then I have a custom Form that implements this interface of mine. It throws an error. VB is the 5th language I've worked in that uses interfaces... and up until now they've all treated interfaces relatively the same. This is the first time I've seen this not allowed. What perplexes me more, is it IS allowed in other .Net languages. Just not VB.

[Code]...

View 4 Replies

IDE :: Intellesense Shared Members?

Jun 22, 2010

Why does intellesense show shared members? e.g:Dim x as doublex.epsi 'Epsilon will show up as a valid member in intellesenseIs there a way to change this behavior?

View 1 Replies

Best Way To Initialize Shared Members In A Class

Aug 23, 2011

I was looking on the interweb to see if there were any good examples on how to initialize shared members within a class while still initializing instance variables.[code]How do I initialize both instance and shared members without re-initializing the shared members every time an object is created from a class?

View 1 Replies

Visibility Of Static / Shared Members

Dec 30, 2009

I have faced with a situation in VB.NET and C# (.NET2) with the visibility of the static/shared members. It seems to me a little strange in VB.NET:

public class A {
private static A instance;
public static A Instance {
get { return instance; }
} public string Name { get { } }}
[Code] .....
Shared member behaves like a class public one I can repeat it to infinite..

View 3 Replies

.net - Access Shared Members In Partial Classes

Feb 16, 2011

I'm writing a WCF-Service and I split up my service class to multiple partial class files, so every ServiceContract-Implementation gets its own file. I have one file however that should contain e.g. members that are used by every partial class file such as a logger. The service is hosted with IIS 7 if this matters in any way.

[Code]....

The code compiles fine, but at runtime I get an BC30451: The name m_Log is not declared Error (Don't know the exact words for it. I get a german message ;) ). I don't think it has something to do with the type of m_Log or a depending assembly because I get the same error if i try this with a String. What am I doing wrong? How can I make this work? Edit: I was trying the same thing in a simple console application without any problems. :(

View 1 Replies

C# - Best Practice For Complex Shared / Static Members

Sep 7, 2011

I took over an ASP.NET application and have found this throughout several classes in the application. The programmers before defined several shared/static variables that act as "complex enums" throughout the application. As a fairly new programmer, it doesn't look like best practice.

Here is an example:
Public Shared SecureCommentsWrite As New Task("Secure Comments Write")
Public Shared SecureCommentsRead As New Task("Secure Comments Read")
Public Shared EditEmergencyContact As New Task("Edit Emergency Contact")
Public Shared DisplayPersonalReferences As New Task("Display Personal References")
Public Shared EditPersonalReferences As New Task("Edit Personal References")

The constructor takes the description, then loads the ID key from the database using a stored procedure (the database is SQL Server.) This seems like a good idea since we deploy this application to multiple databases and want to ensure that we load the ID key that's in that database in case it changes. However, since there are literally hundreds of these in the application, the first load takes a while.

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

Constructor - Whats The Best Way To Initialize Shared Members In A Class In VB.Net?

Dec 8, 2010

I was looking on the interweb to see if there were any good examples on how to initialize shared members within a class while still initializing instance variables. I did find an expression that might fit to the answer:

[code]...

How do I initialize both instance and shared members without re-initializing the shared members every time an object is created from a class? Thanks!

View 2 Replies

VS 2005 Modules Vs Private Classes With Shared Members

Mar 28, 2011

I've read that modules are basically shared classes. For a module though, you can call a method directly without prefixing the module name. So I can do this: methodTest("abc", mod1Enum.enum2)But for a class with shared members I have to fully qualify the method call, and in this case fully qualify the enum:[code]In our conversion from VB6 to .NET the need to fully qualify all calls like this might be an argument for us to bring our VB6 modules over as modules instead of converting them to classes.

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

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

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

Visual Studio 2005 - Shared Method In Cannot Handle?

Oct 22, 2009

(I tried with this question but this code isolates the problem better. I have this code:

Public Shared Sub PopulateTextFields(ByRef stuffList As List(Of Stuff))
Dim aStuff As New Stuff
For Each aStuff In stuffList
DoStuff(aStuff)
Next
End Sub

[Code]...

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

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

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

Dealing With Fractions In .NET?

Jul 5, 2009

I recently found myself in a thread deling with convertions from decimal number to fractions... Being a bit too brusk and dismissing the idea at first.I have now implemented a structure based on code frm Javelia whithc can be seen in this thread.Solitare also proveided code that I eventually understood and was working.[URL]...it a step longer and developed a structure that can also implement calculating with fractions... My first try is also posted in the tread above...

The implimentation is far from perfect, as it does not deal with POW of fractions.. So if anybody has some ideas on hoe to do this with squer root and all pleas let me know and Ill update the code..

[Code]...

View 7 Replies

Create A "shared" Variable That Is Shared With All Instances Of A Class?

Jan 14, 2011

I seem to be drawing a blank. I'd like to create a "shared" variable that is shared with all instances of a class but not classes that inherit from it. For example.Class A: Shared list As New List(Of String): list.Add("A")

Class B Inherits A: list.Add("B")Class C Inherits B: list.Add("C")The end result I'd like is that any instance of A has just A in the list. Any instance of B has A and B in the list. Any instance of C has A, B, and C in the list. I can accomplish it by creating Instance variables, but I have to construct the list for each instance of a class. I'd like to construct it once for a specific point in the Hierarchy and then share it accross other instances of that class.

View 12 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 - Dealing With Large Integers?

Apr 19, 2012

So I am making a file crypter so that I can encrypt my VB.NET Application that I am making so that people can't decompile it. I had made this in C# and am transfering it to VB.NET, Everything worked fine in C# but once I had re-written the code in VB.NET i get this error inside of my RC4 Encryption method:

'Arithmetic operation resulted in an overflow.'

The error is occuring here:

Dim t As Int64 = (s(i) + s(j)) Mod 256

This is the same code above in c#:

int t = (s[i] + s[j]) % 256;

Is there anyway to make that calculation with it erroring? And why does it work in C# but not VB.NET?

View 2 Replies

.net - Polymorphism In .Net When Dealing With Generics?

Jan 6, 2012

I have a function called Modify. It is delcared like so:Public Function Modify(Of SIMType As {New, DAOBase})(ByVal obj As DAOBase) As Boolean

You can see that this function is generic. It takes as a paramer a object that is a DAOBase or subclasses of DAOBase.Inside the modify function there is a call like so:

DAOToGP(obj)This is where the polymorphism comes into play. There are four or so subclasses I have created of DAOBase. I have written a DAOToGP() for each of these types. So in the Modify() function, when it calls the DAOToGP(obj), polymorphism should kick in and it should call the correct implementation of DAOToGP() depending on the type that I pass into Modify().

However, I get the following error:Error 20 Overload resolution failed because no accessible 'DAOToGP' can be called without a narrowing conversion:'Public Shared Function DAOToGP(distributor As Distributors) As Microsoft.Dynamics.GP.Vendor': Argument matching parameter 'distributor' narrows from 'SierraLib.DAOBase' to 'IMS.Distributors'.'Public Shared Function DAOToGP(product As Products) As Microsoft.Dynamics.GP.SalesItem': Argument matching parameter 'product' narrows from 'SierraLib.DAOBase' to 'IMS.Products'. C:Usersdvargo.SIERRAWOWIRESDocumentsVisual Studio 2010ProjectsSIMDev_2SIMIMSDVSIMLibGPGPSIMRunnerRunnersRunnerBase.vb 66 39 IMS

I am kind of at a loss here. I am not sure why it cant figure out which function to call.

View 2 Replies

Asp.net - JavaScript / Dealing With Different Browsers?

Aug 23, 2011

my code works fine in JavaScript but doesn't work correctly in Firefox or safari and wondering why. What I'm doing is I have a loop going through each element and depending on the variable inside a text box just want to alert something. Like i said earlier this code works fine in IE. Here is the code below:

Here is an example of text box:

<asp:TextBox ID="txtMac" runat="server" req="yes" errMessage="Mac"/>
for (a = 0; a < theForm.elements.length; a++) {
if (theForm.elements[a].type == "text" && theForm.elements[a].req == "yes") {
alert("Made it here")
}
}

View 5 Replies

Dealing With Apostrophe In Filter?

Jul 19, 2011

Problem dealing with apostrophe in filter?

View 5 Replies

Dealing With HUGE Numbers

Sep 21, 2009

I've been messing around with prime numbers for a while now, but I now want to use massive numbers, say a few million digits in length. Is there a way of storing and performing mathematical functions with such large numbers? Is it even possible on my home computer? I read on another old thread, something about a big number library, but the links he gave are now dead.

View 4 Replies

Dealing With Multiple Requests?

Jul 30, 2009

I have a website and say a user comes along and fills out the form with bogus data. Then after he fills it out, he enters another one and another one and another one of bogus data. He's basically just trying to clog up the data base.

How is the best way to combat this? Would it make sense to when they submit the data track the IP address?

View 4 Replies

IDE :: Datetimepicker When Dealing With Time Only?

Jan 6, 2010

I sure this has been asked more then once... New to vb.net and I have been experimenting with a datetimepicker and how it looks at and deals with time. What I am trying to do is to add up my time (not worried about the date at all). I have it figured out and can get it to work so long as I do not go over 24 hours... and that is where my issue comes into play.

How do I display my total time in hours once it has gotten over 24 hours ( I do not want days.. just hours) for instance, a 40 hour work week, not 1 day and 16 hours.

[Code]...

View 2 Replies

Sql - Dealing With A Varbinary Field?

Jun 10, 2009

A partner of ours is making a call to a web service that includes a parameter called token. Token is the result of an MD5 hash of two numbers, and helps us authenticate that the user using our partners system. Our partner asks the user for two strings, concatenates them, runs them through MD5, and then calls our web service. The result of the MD5 is the token, and it is submitted to us as a string.

We store valid tokens in a DB - since we use the SQL Server to compute the tokens on our end, SQL seemed to be happiest storing the tokens as a varbinary, which is its native result for an MD5 computation.

We have two pieces of code that attempt to do the same thing - run a select query that pulls out a value based on the token submitted. One uses a dynamic query (which is a problem), but it works. The other one attempts to do the same thing in a parameterized (safer) fashion, it does not work - it is unable to locate the token.

Here's the two competing attempts. First, the parameterized version which fails:

byteArrayToken = System.Text.UnicodeEncoding.Unicode.GetBytes(stringToken)
scSelectThing.CommandText = "select thing from tokenstable where token=@token"
Dim param As SqlParameter = scSelectThing.Parameters.Add("@token",

[Code].....

View 1 Replies







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