Application Wide Shared Methods
Jul 26, 2011
I am developing an application that has multiple forms and I wanted to know the best method to have application wide methods and functions. Currently I am using a Module with all my methods that are needed to be used across the entire application in it. However, I read at one point that modules should not be used, as they are only there to preserve backwards compatibility with older VB code. Is there a better way to have methods able to be called anywhere?
View 1 Replies
ADVERTISEMENT
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
Aug 3, 2010
I've been looking at using PROPERTIES [URL] but frankly I don't understand it that well. Before I invest the time to read, understand, and truly comprehend this, I want to make sure it's the best way. My intended goal is to create my database connection string in a function/sub somewhere, then assign it to this project wide string variable, then I can use it in any form, project wide without having to recreate it.
[Code]...
View 7 Replies
Nov 23, 2010
Have a windows application that "got complex" and new products could use many portions of the existing application.Decided to break app into multiple projects to facilitate sharing the appropriate pieces with new products.One object in app provides a library of text phrases used in the production of output docs.Wondering if such an object should be a set of shared methods instead of instantiating it in every object that consumes these text phrases.
View 5 Replies
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
Feb 25, 2011
As a followup to the previous question I have asked "ASP.Net Architecture Specific to Shared/Static functions" I am still struggling to understand the implications of using shared methods in ASP.NET.
So for example let us take the following code.[code...]
View 3 Replies
Oct 27, 2009
I Want to know which one is preferred while coding to use Static Methods or normal instances, I prefer to use static if they where few but if there was many of them I start to get some doubts
[code]...
if the EmployeeManager Has Many methods (selects deletes updates) is it ok to make them all static.and if it was Normal instance. wouldn't be a drawback if the object is initiated every time specially if GetAllEmployees() is heavily used.What is the better approach to use?
View 3 Replies
Aug 8, 2011
I have a form (frmMain) that contains a custom control (con class). frmMain contains a combo box control and when the user selects a value from it, I pass this value to a sub routine within con class (see red line below). This purpose of the sub routine is to populate a set of comboxes contained in con class according to the value that is passed in.
Private Sub cboGuidelines_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboGuidelines.SelectedIndexChanged
If bChanged = True Then
[code].....
View 6 Replies
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
Feb 25, 2009
If you can't use Me. in a non-instance method, how would you use properties/functions from a base class in a Shared method?
For example, ClassB inherits from ClassA
ClassB has a Shared Method DoWork();
ClassA has a ReadOnly Property SecurityKey
How do I Public Sub DoWork() Dim test as String = Me.SecurityKey End Sub
View 5 Replies
Jan 28, 2010
I have created a Interface and a couple classes that implement this Interface. I am in the process of developing a Shared Class that utilizes the functions that each of the individual classes have, due to the interface implementation.What i need to know is how do i develop this Shared Class so that way each of the methods within it are restricted to a single data type. This single data type needs to be restricted to any class that has implemented the Interface.
Some examples:
Public Interface IVector(Of T)
Sub Add(ByVal v2 as T)
[code]....
As you can see it would allow me to develop one form, since i have standardized the required Subs/Functions for any class the implements the IVector interface. As i am still in developement, i was wondering if my current understanding of the method generics is correct in its current form or what i would have to do to make the Generic Shared Class work in the fashion that i am looking for in the example implementation.
View 6 Replies
Aug 3, 2009
I want to create a subclass of a class that has some shared methods. These shared methods all call one specific method. But I can't redefine that specific method in the subclass. If I try to make it overridable in the parent class, it says that shared and overridable can't both be used.
[Code]...
View 5 Replies
Jul 9, 2009
I seem to find more and more that I declare a lot of objects or methods as Shared now but it feels like I am not doing things properly.I try to avoid doing this but then I just end up with situations where I have to create an instance of a class just to call one method that would act no differently if it was just a shared method.Basically I'm just wanting to know if there is any good reason to avoid using Shared objects/methods. Obviously I dont declare EVERYTHING as shared, but it just seems to make things a lot simpler most of the time.For example in my current project (a chat application using WCF) I have a class just called Core which houses a lot of the main functions of the client program, so it has methods such as: SignUserIn, SignUserOut, SendMessage, MessageReceived etc and it also holds properties such as a list that contains all of the currently online users. These things are all declared Shared in my program because as far as I can see there is no reason for having to do this:[code]
View 15 Replies
Jan 25, 2010
I have the following class in a .NET class library:
Code:
Public Class JasonTest
Sub New()
End Sub
[Code]....
The .AddNumbers call works fine, but the AddStrings call yields the error 'Object doesn't support this property or method'.
Is there any way to call a shared method from .NET in VB6? I was unable to find any documentation on this.
View 5 Replies
Dec 20, 2011
I now have a need to dynamically load a dll into my application and I've found the reflection/assembly information and it's fairly easy to implement so I thought I was on my way. However, I quickly found out that I'm only able to use 'shared' methods. What I was originally thinking was I could have one shared method 'library.beginprocess' and then that would make all the necessary calls to the other methods, but this doesn't work unless all the other methods and class level objects are also shared.
I feel like I'm missing something or somethings just going right over my head. I've looked at many, many sites and examples, but I've only run across examples that expose 1 method,[URL]..which explain how to implement a plugin architechture, which I have not tried yet, but maybe would allow me to keep my class structure the same without having to make everything shared?
View 14 Replies
May 14, 2012
I want to extend the BitConverter class with an overload of ToString() that takes a parameter of type Char, representing a value delimiter.Why? By default, the ToString() call returns a string representation of a byte array, delimited by dash symbols. The signature does not allow you to specify a different delimiter, which I find very unfortunate.Now because this is not an instance type, or maybe because I'm overloading a shared method, I'm having a hard time finding the proper syntax to define my extension method.What am I doing wrong here, causing the overloads to not show up in IntelliSense:
Imports System.Runtime.CompilerServices
Module BitConverterExtensions
<Extension()>
[code].....
View 1 Replies
Oct 21, 2009
I have a List(Of AddlInfo) with AddlInfo being an object. I'm trying to pass addlInfoList by reference into a function of another class:
[Code]...
This works if I'm not passing the reference into another class, but when I try to do this, I get the following error: Overload resolution failed because no accessible 'Sort' can be called with these arguments:
[Code]...
View 1 Replies
Oct 11, 2010
What is the purpose of using shared methods that return an instance of a class, as opposed to a constructor?
ie: in VB.net, the system.drawing.color class has shared method "FromArgb(int, int, int) as color". This is different from java's implementation which simply is a constructor that takes three ints. Why the decision to do one or the other?
View 1 Replies
Jun 4, 2011
I'm wondering what will actually change a class, in the sense that serialized objects of this class will no longer be recognized. If the class has reference to shared methods of another class. Will changing such shared methods also change the classes that reference them?
View 3 Replies
Nov 15, 2010
So I implemented my own form of Enum static classes so I can associate strings to enumeration values. One of the shared functions in each enum class, GetValue, is used to quickly look up the string value from an internal array via the offset. While all of the enum classes implement the same exact function, the data types of their parameters differ, specific to the enums in each class.
So I come to a point where I want to create a generic class that can use any of the enums by passing it as a generic type parameter. But I cannot find a way to constrain type T in such a way to be able to call each enum's GetValue function. This is where an interface would come in handy, but VB.NET forbids interfaces for shared methods.
I have a base class that I could constrain to, but the base class doesn't implement the GetValue method, and I can't define a generic version of it, because I need to rely on shared properties of each child class in order for GetValue to do its thing.[code]..
View 2 Replies
Oct 25, 2010
i need to store Application wide Settings in my Application like:
Connection to DB (Servername) Username/Password Registrar/Serial etc. I think there are basically two Options:
Store them in the Registry Store them in an Application Settings File Using one of the methods above is no problem, but under Windows 7 my Application running in normal user mode allows me only to store user specific data. For example inside UserAppDataRegistry, UserAppDataPath etc.
But when i want to use e.g. CommonAppDataRegistry to write my Data in, then i get no access to it, due to missing privileges.
Now my question:
Where and how to store Application Wide Data? How are others doing this? When i purchase an application and install it on my pc, it asks me for Uusername and Serial. When i insert it then it saves it somewhere without asking me for Administrative Privileges or something else.
View 14 Replies
Dec 28, 2009
I have a license form that i wish to save the information or just system wide information for that matter,I know about the my.Settings - however this will only save for a specific user and the aplpication scope you can not write to.Where is the best place or the normal practice of saving application wide information?
View 7 Replies
Mar 26, 2009
How can I set up an application wide event trap that is triggered when my database connection status changes?i.e. no matter what form the user may be on if the connection is terminated for whatever reason a message box is displayed to the client requesting whether the program should try and reconnect with the database or not.
View 9 Replies
Jun 6, 2009
Is it possible to write a Gloable or application wide error handler, how?
DanielI'm new to .Net, OPP and this forum but love it!
View 3 Replies
Aug 29, 2011
This is the original code in c#
public class CategoryRepository: RepositoryBase<Category>, ICategoryRepository
{
public CategoryRepository(IDatabaseFactory databaseFactory)
: base(databaseFactory)
[Code]...
Does anyone has an idea what i should change to let it work and let my UserRepository use the methods in RepositoryBase while implementing the IUserRepository?
View 1 Replies
Jul 5, 2010
I've been trying several methods to simulate a scrolling news ticker on an application. There is a lot of activity within the program, so I need to keep the ticker on a seperate thread.I have made a timer which when a tick is hit (in this case, every 100ms), executes a sub which removes one character from a label to simulate the ticker. This works quite well, although when the program does something else the ticker freezes up momentarily. I am wondering if someone could give me some advice on the best way to eliminate these freeze ups? How could I execute a new thread every 100ms to move the ticker? I was thinking of somehow using a threadpool for each time the a tick is hit on the timer, but I'm not sure how, or even if this can be accomplished.
View 10 Replies
Mar 17, 2010
i have an multi-threading applicaton. so I am using system.threading.thread class to create thread. each threads call its own class and inside each class i am accessing webservices. I need to have status returned from each webservice. thats why I defined a shared property as list of generic object which will be updated within each class called its thread. but I have an hesitation that when I run application on the server. this shared object will be used by all instances of web application. Is it true or shared properties is used only for its own instance?
View 5 Replies
Jun 1, 2009
I've created an application that is on a shared drive and everyone can run it. I want to be able to close all the running instance of the application by sending it a command. How can I do that?
View 7 Replies
Jul 28, 2009
I have a VB2008 application that runs off a server. Users connect to the application via shortcut.
[code...]
For what it's worth, the application is targeting .NET 2.0 Framework on both the development side and package install side.
The illustration below is more for my sake than yours, but should help me explain the problem.
User A and B work just fine, but when User C and User D attempt to use the program via shortcut9(same as User A and B) the error below is displayed.
[code...]
what I can do to allow User C and D to use the application?
View 11 Replies
Jan 12, 2012
Basically i am creating a vbnet system software. I want to create a shortcut key to lock the system with out affecting the windows explorer (just my system only). Is it possible to create one for that? Or let's say create a procedure that triggers anywhere whether the focus is on a control, on a form (whether shown as normal or modal), or on any other that has the focus on it.
View 1 Replies