VS 2008 : Have A Class Where The Functions Of The Same Name Are Both Instance Functions And Shared Functions?
Dec 6, 2010
What I am trying to do is have a class where the functions of the same name are both instance functions and shared functions.
Public Shared Function Get...(byval xx as xx)
and
Public Function Get...
The Public Function uses a Property xx created in the constructor, whereas the Shared Function has the parameters (byval xx as xx).
View 1 Replies
ADVERTISEMENT
Feb 11, 2009
I have large group of functions that I would like to store in basically a library and simply call the functions from the controls on my forms. Back in VB 6 I would have done this with a module, but now I have been told that a Public Class is the correct way in .NET. How should I go about doing this?
View 2 Replies
Feb 3, 2011
Namespace MyClassLib
Public Class MainClass
Public Sub New()
[CODE]...
Is it possible to make it so that the user using the Class Library has to declare a new Instance of MainClass() before using Subs/Functions in Class2 or Class3?
View 2 Replies
Aug 9, 2011
I would like to understand the Pro & Cons in using the commonly used methods via Singleton class against Shared (Static) members of a class in VB.Net. It could be in terms Time, Space complexity or best practices. I have a BankAccount class with methods doing some business logic.
GetBalance()
GetLast5Credits()
GetMiniStatement()
[code].....
View 4 Replies
Apr 22, 2010
I've got a BaseDataClass with shared fields and functions
CODE:
I have several classes that derive from this base class. The derived classes have all Shared functions that can be called directly from the BLL with no instantiation. The functions in these derived classes call the base Init(), call their specific stored procs, call the base CleanAll() and then return the results.
So if I have 5 derived classes with 10 functions each, totaling 50 possible function calls, since they are all Shared, the CLR only calls one at a time, right? All calls are queued to wait until each Shared function completes.
Is there a better design with having Shared functions in your DAL and still have base class functions? Or since I have a base class, is it better to move towards instance methods within the DAL?
View 1 Replies
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
Jan 29, 2007
1) Is it possible to access the Excel mathematical functions without actually opening Excel?
I was thinking of through a DLL WinAPI call or maybe a delegate function or smaller program?
2) Does anyone know of a MS link or area that gives instruction on "how to" use every function of every Windows DLL at all?
Or for all those that Microsoft have chosen to document online at least.
View 1 Replies
Feb 19, 2009
While converting types, I have found myself using both VB functions and BCL Convert.To* methods.
E.g.)
Cstr() vs. Convert.ToString()
CInt() vs. Convert.ToInt32()
CDbl() vs. Convert.ToInt64()
etc...
Are there any subtle differences that should be noted?
View 1 Replies
Mar 4, 2009
Is there a way to see exactly what the functions are doing. What i mean is there a way to see the class? I know what it does, i just want to know the code.
For example the function: Membership.FindUsersByName()
View 1 Replies
Jun 6, 2009
I'm looking at a VB.NET class (that I didn't write) that is declared "MustInherit" (abstract in C#, I believe) that has three methods, all of which are defined as "shared" (static in C#). There are no properties or fields in the class - only the three methods. From an OO perspective, does this make any sense?
My thinking is no, because by making it MustInherit, you're essentially saying you can't create an instance of this class - you must inherit from it and create an instance of the derived class. But since all the methods are shared, you'll never actually create an instance of the parent class anyway, so the "MustInherit" does no good. You might as well not mark it MustInherit and just inherit from it whenever you want.
View 3 Replies
Jul 31, 2009
I am working with VB.Net and am kinda new. I was wondering, if my asp.net project has a lot of shared functions, can I put them all into one Namespace? Do I have to put them into a class?
View 7 Replies
May 21, 2009
I was wondering how to implement a vb script file with functions and subs that can be used in all code pages of a project. Similar to the old VB 6 bas files.
View 2 Replies
May 21, 2010
I've created a global sqlConnection in my app and it works fine for sharing the connection between functions. I have also defined a global sqlTransaction that I'd like to share between functions also, so I don't have to pass it around during a complex update but it's not working as I hoped.
Module Master
Public sqlConnString As String
Public SQL As String
[Code]....
View 7 Replies
Aug 20, 2010
I get this error: Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class.
Partial Class _Default
Inherits System.Web.UI.Page
<WebMethod()> _
[Code]....
I know it has something to do with the fact that the first function is shared and the second function should probably be Public as well but I don't fully understand the reason behind it. Probably not relevant but I'm calling the web method from some javascript.
View 1 Replies
Jul 31, 2010
Are the following three the same upon compilation
dim x as new assigningfunction
dim x as new assigningfunction()
dim x as assigningfunction = new assigningfunction()
[code].....
View 4 Replies
Jan 29, 2010
I have an asp.net web app. It has a shared class, and I want to have the connection string the same through out the site. My string is in my web config, but I don't want to type this all over the place:
View 3 Replies
May 19, 2009
Is it considered an acceptable practice to use Modules instead of Classes with Shared member functions in VB.Net?I tend to avoid Modules, because they feel like left over remains from VB6 and don't really seem to fit in anymore. On the other hand, there doesn't seem to be much difference between using a Module and a Class with only Shared members.
View 4 Replies
Feb 1, 2011
I am porting an app from VB6 and I run into problems with references to functions and subs. Basically, let's say I have 2 classes added to the project, like this.
Public Class OOOOO
Public Shared Sub BBBBBBB(ByVal FileName As String)
...
Call CCCCCC()
Call DDDDDD()
etc.
...
End Sub
[Code] .....
I had to make the BBBB() shared to be able to call it from another function AAAAAA() from another class PPPPP. However, I get error on the references in the BBBBB(), that CCCC() and DDDD() have to be made also shared (so instead of 1 error I got number of errors).
When I tried to make them shared as well, I got tens and tens of errors due to other references of both variables and functions.
View 4 Replies
May 19, 2011
Well I am a new to VB.NET, converting a legacy system to .NET world. Recently I have been reviewing the already existing code since I joined the project quite late in the team. I find that there are many shared functions (not shared class) inside many classes. I doubt this may create some problem if two requests ( i.e two different HTTP request to the same method as it's a WCF application, of course exposed methods are not shared but internally called methods are shared) comes to the same shared method and both the calls to the method may have different method parameters/arguments, overwriting each other's arguments. In short, if shared method has a list of arguments which is going to be processed, is there any chance of inconsistencies in the light of multiple access to the shared method via two http requests.
View 2 Replies
Jul 22, 2009
give me a good resource that explains the difference between a Private, Public, Shared Functions/Sub/Variables? I normally use Public for Subs/Functions inside of Modules I call from other parts of the program. But I'd like to get more of an understanding of how and when to use them. I want as little as impact to a system that is running my programs as possible, so i guess the key here is I'm trying to just get more proficient in my coding.
View 8 Replies
Dec 6, 2009
If I have two threads both calling a normal function at the same that appends strings, sometime the output string is a combination from both threads as the function had not finished executing the code before it was called again... Would a shared function wait to finish first?
View 9 Replies
Jul 1, 2011
I'm redoing a program for my company and my boss wanted me to created the entire thing through functions...
For the task I wanted to know is it possible to have functions within functions?
Sort of like in C where we would have nested structures?
Its a FILE I/O, with robot commands, moves and verifications....
So I would find the line in an excel spreadsheet where it moves, the coordinate, put it into an array.
Take the actual results store them into a two dimensional array...etc, etc....
Another function would eventually compare the results with the moves, and within a tolerance.
View 9 Replies
May 9, 2010
I am currently trying to write classes so that I can access certain functions from any form within my VB project.
My class is defined thus:-
Public Class testclass
Public Function showmes()
MsgBox("Hello everyone"")
Return 0
End Function
End Class
I have added the class into my form using this at the top in the form:
Imports WindowsApplication1.testclass
Obviously, WindowsApplication1 being the name of my project, testclass being within a VB file, saved with my project.
I have attempted to call the function from the form using this:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
showmes()
End Sub
However I am getting the error "Reference to a non-shared member requires an object reference." I don't understand why there is a problem, since I have used imports to reference the class.
View 6 Replies
Jul 30, 2009
I currently have a VB.NET class named "Customers" and it's been steadily growing in size and I now have a couple dozen functions in it. Is there a way of maintaining the functions in the same class? Since they still use common private methods, but group them by similarity.[code]I guess I wasn't clear on where I wanted this grouping to occur. I want the groupings to be almost like namespaces/classes in IntelliSense when I use my Customer class.I currently use Regions but they only help when seeing the code, not when using the class.
View 6 Replies
Feb 18, 2011
I am new to .NET 4 and VS 2010. I am using VB 2010 and have made a class and need to know how i can access those functions in the class within another form. So there is a function say of XYZ in the class named classes.vb and need to get to it from form1.vb
View 9 Replies
May 2, 2009
if anyone knows if I can get a listing of all of the sub/functions in a class/module. Just the definitions (That is, the name, paramaters etc., but not the code).
View 3 Replies
Apr 26, 2011
I have recently started learning VB.NET. I created a simple 3 tier windows application. The DAL project contains a class with a number of functions. In the BLL project, I've added a reference to the DAL project, but I still can't access the functions in the DAL class from the BLL. However, if I change the DAL class to a module, I can access them then. Both the DAL class and its functions are public.
View 1 Replies
Oct 4, 2008
This is very basic about the layout of classes, subs etc. 1. Should all my subs & functions always be inside a class? I haven't used classes too much before, mostly just a bunch of subs in a form file. Now I downloaded a sample program which I want to develop. This has all the code of the form inside "Public Class Form1": [Code] The code is an example of use of the ZedGraph library. It produce a simple window with one graph/chart. Now I want to develop this code with several tabs, a dusin different charts, file I/O and so on. I'm ok with most of the specific coding, but my question is on the general coding;
2. Should I continue my subs&functions inside this form? inside this class? inside a new class? Earlier when I've NOT been using class, I can make global variables by placing the "Dim" outside the subs. This does not seem to work within a class. 3. Should I avoid global variables all together, or how is this done without always passing arguments?
Also I will make more forms, for program options etc. 4. Should these forms be coded as classes? or just subs&functions in a form? Obviously I'm not well trained on the proper use of classes and have trouble to find this easily explained.
View 2 Replies
Sep 3, 2010
i am comfortable with class, namespace ,Sub ,Function ,Properties ...and so on. i studied about Custom Controls and Extension methods. There i found something new so called Attribute that are placed before classes and Functions definitions.[code...]
View 4 Replies
Mar 1, 2010
I need to create unit testing project for my current website. The currentw ebsite si written in VB. All unit testing examples are using interface to create mock object. My current VB class does not implment any interface. Can I add interface and implement it to my current class and functions without affecting or changing codes to any pages in my website that call the functions? For examples my current class is like:
[Code]...
View 2 Replies