Make A Class And Implement Tostring?
Jan 10, 2010If we make a class and implement tostring, should we support some interface?
View 5 RepliesIf we make a class and implement tostring, should we support some interface?
View 5 RepliesI 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]...
Suppose I have piece of code like this:
Public Interface ISomething
....
End Interface
[code]....
I am working on a general helper class to sort ListView SubItems. I wrote a base class that has much of the code I need. It includes a MustOverride for the Compare method so that the various inherited classes can implment their own comparisons based upon their type. For the value types, I end up with very similar code such as the following, where x and y are ListViewItems: Public Overloads Overrides Function Compare(ByVal x As Object, ByVal y As Object, ByVal sortColumnIndex As Integer, ByVal sortOrder As System.Windows.Forms.SortOrder) As Integer [code]
View 3 Repliesclass inherit from another class and implement an interface?
View 4 RepliesI just would like to know how to implement class constructor in this language.
View 2 RepliesI want to modify the base Array class by creating a new class called "FileArray".I have some text files that are read into a string array. Each element in the array is a line from the text file. I want to update the GetValue method by overloading it or overriding it so that it will update some value that will give an indication to what the last line was. I have a couple of ideas on how I can do this:
1) Use a public integer, like intLine, that gets updated everytime GetValue is called.
2) Create a new property of Array, such as "LastLine" that would return the last line number (which would basically be the last index value +1) and then use a public array to store the files (though this is less desirable as the array may be used by several different functions)
An easier way would be to be able to determine the last element that was returned, which is basically what I think I am describing above.
Say I want to know more about a class mshtml.htmlinputelement for example.Say I want to know. What is his parent classes? What interface the class implement? How do I do so through object browser?
View 1 RepliesI am trying to build a class. I am having a difficult time conceptualizing how a class is built and how it works. I want to be able to build a USEFUL class and implement it in an application.
View 1 RepliesImplement singleton in a parent class.Infact what I want is that All the childs etc. should use same instance of the parent.
I have implemented singleton, Changed the scope of parent class's constructor to "Protected". But in the application when ever the new child's constructor is called i.e. "Dim abc as New Ch1()" the constructor of Parent is called (as it is Proctected and can be access from child).
I've never actually used Reflection, but I've been warned in the past that using it may cause slow performance. My question is what part(s) of it is/are slow.
I'm thinking about creating a board game and I wanted to implement the player class through plug-ins. That way there could be several different player classes (i.e. human players, and several configurable AI classes). If implemented this way, where should I expect performance hits? Only when initializing the player class? When passing arguments to methods in the player class? In the entirety of execution of methods from the player class? Or is it going to affect the whole application?
The reason I ask is that the AI will be extremely processor intensive. Through testing it seems like it may take around 1-30 seconds to determine a move on my quad core (Core 2 Q6600) processor, depending on the effort spent to optimize the move and testing different branches on separate threads.
My concern is that if I implement the AI via a plug-in, the move determination would slow down considerably to the point where it wasn't playable on lesser hardware.
I have several similar classes but only want to instantiate one of these classes dependant on a selection from my main form.
View 4 Repliesi cant seem to find an answer to, i recently decide to start using class libraries, but cant seem to figure them out. I need to be able to assign the class details to fields within my texboxes and controls found in the Tab, i have placed an image with a basic layout of the controls on the tab. My question is: 1stly how do i make it so that the class library performs the function within the tab without having to create a seperate form for it with its own controls(or do i need to do that?)Secondly: In the next tab, can i create a seperate class library for it if it performs another task such as issue? how to create and place them as refferences, i just cant figure out how to marry the controls?
View 14 RepliesIm getting the following error on the code I transleted from C# to VB.NET below (original code can be found here:
Class 'QueryParameterComparer' must implement 'Function Compare(x As oAuthBase2.QueryParameter, y As oAuthBase2.QueryParameter) As Integer' for interface 'System.Collections.Generic.IComparer(Of QueryParameter)'.
[code]......
How does one implement something as Public ReadOnly Property within a class.
CODE:
1. What's the difference between ToString and ToString()? (i do know that ToString method is to cast numeric values to string but don't know how to get it to work)
2. Why do i need XML comment feature? is it necessary?
link that implements DES algorithm with CBC. if I want to use an existing class to implement the standard DES (using ECB) to encrypt file, how do i do? I want to use this class because it implements each step of the algorithm.
View 4 RepliesI've now properly started implementing OO into my system (which I probably should have done from the start) but I just want to clear some best practices.So let's say I have a class called Job which contains information such as Description, Project Manager (Employee class), Value etc. at the moment, if I initialise the Job class it will initialise all the information held within it, even if I only want the job description. Is it best practice to do this or is it better to implement the class and access the database for values as and when they're needed? Or is it just better in those cases to just access the database directly?
View 1 Replieshow variables declared with protected access in a base class are used to implement inheritance.
View 1 RepliesI created an interface - TermsService.vb and defined the following method : Function GetTermsList() As List (Of Terms)
how do I modify my TermsDB class to implement the TermsService interface I've just created? Here is my code: Have I implemented it correctly?
Imports System.Data.SqlClient
Friend Class TermsDB
Implements TermsService
[Code].....
I am in the beginning stages of writing a VB.NET application for our customer's pc.This app will monitor machines through a serial port and display the status of those machines on the screen. In the future, we want to be able to run this program both on the pc and from any computer connected to the internet. What steps should I be taking now to make the web access step easier to implement?What is a good resource for learning how to make an application web accessible?
View 3 RepliesI can't make difference between public class and private class and friend and protected friend class.
View 1 RepliesI am New to <acronym title="Visual Basic">Vb</acronym>.Net. this is my first test. i try to create small address book. but i don't know what wrong. it compile perfect but when it run it give error and not work. is there any other way to add same class like in class inside array?
[Code]...
Public Class form1
Private Sub btnAnswer_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAnswer.Click[code]........
how can i make vb realize that the side that is opposite of the given angle, has to be less than the other sides. Also im not sure what Acamar meant by If txtAngleA.Text <> "" AndAlso txtAngleB.Text <> "" AndAlso txtSideA.Text <> "" Then 'two angles and a side Because im not sure what <> does.
Can i make obejct of a VB class from C# class, if possible then what i'll have to do?
View 3 Repliesok so i've got a Form class that inherits from System.Windows.Forms
the problem is that once i put that line in, the IDE automatically converts it into a class that has Designer enabled. how do i stop this behavior?
I have no idea how to do this, but I want to create a [I dont know what it is called] to allow me to convert a class property to another type.The I could use the following w/ the new type:
Dim stringPhoneNo as String = "(111)111-1111" Dim typePhoneNo as PhoneNumber = stringPhoneNo.ToPhoneNumber()
When a custom class overrides the ToString() method, the C# IDE uses this function to display the class in the debug mode(tooltips, watcher etc) Does the VB.NET the same? I have impression that overriding ToString() method does change nothing. I mean, in the watcher I see Name myBusinessObjectInsnace Value {MyNamespace.myBusinessObjectInsnaceType}
View 4 RepliesIf you try to compile the query below in Visual Basic .NET, it fails. From x In {1, 2} Select x.ToString() The error given by the compiler is: Range variable name cannot match the name of a member of the 'Object' class. There is nothing wrong with the equivalent C# query, though: from x in new[]{1, 2} select x.ToString()
This does not happen with the ToString overload that takes a format (it is a member of Int32, not Object). It does happen with other members of Object, as long as they don't take an argument: with GetType and GetHashCode it fails; with Equals(object) it compiles.
My problem is that I'm trying to parse a String to a System.Drawing.Color. Im trying to set up a simple notepad, here's part of my code:
Private Sub ToolStripMenuItem6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Colorfuente2.Click
Try
Dim cdlg As New ColorDialog[code].....