Remove The Add / Delete Methods From The Class
Feb 17, 2012
I created a Class that inherits List(Of TKey, TValue) and adds a few functions. Its purpose is not to add items to it at runtime, but when it is initialized. I would actually like to remove the add/delete methods from the class (as it currently exposes them from the inherited class).
[Code]...
View 2 Replies
ADVERTISEMENT
Mar 29, 2010
I am not sure how clear my question is by the title, but I am trying to make Class methods instead of Instance methods in Visual Basic that way I don't have to waste memory and code creating temporary objects to execute methods that don't need instance variables.
I am not sure if you can do that in VB but I know you can in Objective-C by using either a "+" or "-" sign in front of the method declaration. And in C++ (at least I think, I can't remember) you put the static keyword or const keyword in front of the function.How would I do this in VB if it is possible? Or should I just make a separate set of functions that are not members of a class?
View 2 Replies
Dec 24, 2010
I was wondering about the EventInfo.GetRaiseMethod and EventInfo.GetOtherMethods methods. Apparently, the CLR supports 4 kinds of methods associated with events: add, remove, raise, and "others". But events created in C# only have add and remove... I assumed that raise was used in VB, since you have to specify a RaiseEvent method when you declare a custom event, but apparently it's not the case: GetRaiseMethod always returns null.what's the point in having a raise method associated with an event if it's never used? Is there a specific MSIL instruction to raise an event using this method? (I couln't find anything like it in the opcodes)what are the "other" methods returned (well, not returned actually) by GetOtherMethods? What's are they supposed to do?are there types in the BCL that implement those special methods?
View 2 Replies
May 27, 2009
If I have an ObjectDataSource setup like:
<asp:ObjectDataSource
ID="ObjectDataSource1"
runat="server" [code].....
How do I get the objectdatasource to use the Delete method with the parameter that is not an Employee object? what is the recommended alternative architecture?
Edit:
To clarify, I want to use the method signature on my data/business object as shown above, however if I try to allow an Employee object to be passed into some of the methods using DataObjectTypeName, then I seemingly lose the ability to have some methods take just an integer id for instance.If I do not use the DataObjectTypeName, then I have to place all the method parameters in the ObjectDataSource and change the methods on the data/business object to match, this seems like a bad design choice because as the Employee object changes I will have to update each of these methods.
View 6 Replies
Jan 11, 2011
Just had to remove remove statics and use Delegates refering to class. i have got a little problem in one of my project.I need help to resolve it.My application Connect several FTP server with the same Class.I'm using TCPclient for few specifics Commands.The problem : All threads call the same TCPclient wich can't connect several server at once.I would like to create a New TCPclient for each thread.
[Code]...
View 8 Replies
Jul 18, 2012
How can i remove an array item by selecting an item from listobx and press remove/delete button?for an example, if i want remove index 2 from listbox, so the array should remove index 2 item and move the item of index 3 to index 2 and so on.
View 7 Replies
Sep 14, 2011
my question is simple. How do i add methods to the standard DataGridView control of VB.NET
I want to add some methods of my own to the class, but i tried inheritance and i get errors. What are the techniques out there to extend native classes in vb net
View 1 Replies
Dec 18, 2011
Example ^. I must be forgetting something or being really dumb.
View 3 Replies
Jul 16, 2011
In this project I am making a grade calculator; I am modifying an existing code I have to have the following characteristics: I need to modify the DetermineGrade method so that it accepts the maximum number of points that can be earned on both tests (currently, the max number of points is 200: 100 points per test). For an A grade, the student must earn at least 90% of the total number of points. For a B, the student must earn at least 80%. For a C, at least 70%. For a D, at least 60%. If they earn less than 60% of the total points, then grade is F. Here is the exisint code I have for the DetermineGrade method specifically:
Public Sub DetermineGrade()
Dim intTotal As Integer
intTotal = _intScore1 + _intScore2
[code]......
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
Aug 4, 2010
I have a class definition that I've seen other define properties that return collections of objects.
Public Property GetAllAdults() as Adults End Property I made the argument that this should be a method in the class, because it doesn't define an attribute of the class, and could not be extended with parameters. Is/Are there reasons why this should be defined as a property vs. a function?
View 3 Replies
Apr 23, 2012
I have a Public Class called "ClientConnection". Inside that class, I have a Public ReadOnly Property called "FileTransfers(ByVal TransferID)". The property returns an object of the class "FileTransfer". All methods in FileTransfer are set to public.
VS is able to discover the methods inside the parent class "ClientConnection". How would I expose the methods inside the sub-class "FileTransfer" that is returned by the property "FileTransfers(ByVal TransferID)"?
Public Class ClientConnection
'irreverent code removed
Public ReadOnly Property FileTransfers(ByVal TransferID As Integer)
[Code].....
View 1 Replies
Jan 24, 2009
I have a database table called Job. I have mapped this table using LINQ to SQL so that I have a class called Job.
What I want to do is add some methods to the Job class. The Job class is defined in the LINQ to SQL classes .dbml file. So, in order to add methods, or anything else to the Job class what should I do?
Should I create a partial class named Job and define the methods in there? Will that then get mixed in properly? Not sure how to proceed on this one.
View 1 Replies
Aug 3, 2011
Do I have to instantiate description every time for different method? Or should I use static? Here's how I'm doing this now: What is the best way of handling this kind of situations. it seems that I repeat this line:Dim description As BLLDescription = New BLLDescription() without any good reasn.
Protected Sub Button8_Click(sender As Object, e As System.EventArgs) Handles Button8.Click
Dim description As BLLDescription = New BLLDescription()
[Cdoe].....
View 2 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
Oct 29, 2009
Is it possible to iterate through the properties and methods of a custom class, getting the details about those properties and methods in the process.[code]....
View 2 Replies
Mar 26, 2010
I have a database table called Job. I have mapped this table using LINQ to SQL so that I have a class called Job.What I want to do is add some methods to the Job class. The Job class is defined in the LINQ to SQL classes .dbml file. So, in order to add methods, or anything else to the Job class what should I do?Should I create a partial class named Job and define the methods in there? Will that then get mixed in properly? Not sure how to proceed on this one.
View 2 Replies
Aug 22, 2011
I have a database table called Job. I have mapped this table using LINQ to SQL so that I have a class called Job.What I want to do is add some methods to the Job class. The Job class is defined in the LINQ to SQL classes .dbml file. So, in order to add methods, or anything else to the Job class what should I do?Should I create a partial class named Job and define the methods in there? Will that then get mixed in properly? Not sure how to proceed on this one.
View 1 Replies
May 30, 2012
In VB.NET or C#, is there a way to determine if a class has been extended with extension methods?
View 3 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
Sep 13, 2010
I want to retrieve private (implementation and other) methods of a class which implements an interface and also is derived from (inherits) a base class.How can I achieve this using reflection?This is wat m tryin to do. I need to view these private methods and their contents, I don't want to invoke them.
Dim assembly As System.Reflection.Assembly
Dim assemblyName As String assemblyName = System.IO.Path.GetFullPath("xyz.dll")
assembly = System.Reflection.Assembly.LoadFile(assemblyName)
assembly.GetType("myClass").Getmethods(Bindings.NonPublic)
assembly.GetType("myClass").GetMethods(BindingFlags.NonPublic) isn't working
View 2 Replies
Mar 3, 2011
I will preface this by saying Im previously an asp developer and am learning oop programming/Vb.Net
Im working on a 3 tier architecture and trying to abstract my code as much as possible since I have a very large intranet to convert. In my business layer I am defining my classes with management methods. Below is an example of one of my classes.
My question: Is there a way for me to genericaly refer to the class type and object type so that I dont have to continualy refer to the class name/type "ServiceRequest" throughout the class. For example something like:
[Code]...
View 1 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
May 27, 2010
How should class member variables be used in combination with class methods?Let's say I have a class 'C' with a member variable 'someData'.I call C.getData(), which does not return a value but instead puts data in C.someData. The class that instantiated 'C' first calls C.getData and then uses the data by accessing the member variable C.someData.I call C.getData() in the class that instantiated 'C' which is a function that returns data.I myself prefer the second way. But it also depends on the situation and it's a small difference. Is it 'bad' to have class methods that depend on the classes internal state? What are the best conventions?
View 2 Replies
Nov 4, 2011
Whats the difference between these two initialization methods for obj? I've seen both of these, but know know if there is an appropriate time to use one vs the other. I found this post which covers C#, but not sure if the same applies to VB.Net.[code]
View 3 Replies
Oct 25, 2011
I have a method with a custom attribute that lists other methods in the same class that it can call. I'm passing the called method to another class function that will read the attribute and pick one of the methods named in the attribute and return it's delegate. I'm having a hard time figuring out how to do this with reflection or event if it is possible.
<AttributeUsage(AttributeTargets.Method, allowmultiple:=False)>
Public Class ExecuteSimiliar
Inherits System.Attribute
[Code]....
View 1 Replies
Nov 27, 2009
What is neater / better in your opinion? Inheriting a Class with useful methods or a creating a module?
For example:
vb Module Tools_Module
Public Sub Print(ByRef text As String)
Console.WriteLine(text)
End Sub
End Module
[Code]...
View 2 Replies
Jan 20, 2011
I am trying to figure out the best approach for setting and getting properties in a nested class I am creating. I have a class, Car which has a nested class ControlPanel and want to make the properties of the Control Panel only accessible to the Car and Control Panel class.
[Code]...
View 5 Replies
Mar 24, 2010
I'm not sure I used the right lingo in the subject header. But, here's what I want to do. Let's say I have a class with some variables:
Class XYZ
Public InfoNo1 As Integer
Public InfoStr1 As String = " ".PadRight(200) 'Hahaha
Public InfoStr2 As String = " ".PadRight(100)
End Class
I've been looking around for examples of writing methods that act on variables defined within the class. What I want to do is make it so that doing something like this:
[Code]...
I don't need to know how to write the method, I think I can do that. I need to now how to make the method cause a ".Fixed" option to be added to the class string variables so that assigning a string using that method will cause the variable itself to be equal to the string plus the padding.
View 39 Replies
Nov 11, 2010
I came across a DbParameterCollection object, which should have an "Item" property inherited from IList, but IntelliSense does not show this object has the Item property.
View 2 Replies