I have written a method to replace multiple characters in a string. Is it possible to overload my own method to the existing method "Replace" in the String namespace?
Function Replace(ByVal inValue As String, ByVal ParamArray replacechars() As String) As String For i As Integer = 0 To UBound(replacechars) Step 2
[Code].....
As you can see it have a different signature from the public method so I think it would be nice to have my method overloading the existing method
I can live with it if it isn't possible. See it as a "nice to have"
I have an inline lambda expression that I would like to use throughout my application. I just can't seem to find a reference on how to do this with more parameters than the element being tested. Here is a quick example of what I currently have.
Private Sub Test() Dim List As New List(Of String) From {"Joe", "Ken", "Bob", "John"} Dim Search As String = "*Jo*"
Consider a MyForm class that contains a shadowed implementation of Show(). It also contains a CreateForm() method, which accepts an instance of the form and calls the shadowed sub:
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:
I have a windows service that I have been writing in Vb.Net. As part of this service it calls a class that has a long running Process.I can execute commands to this process when I want to via the ServerCommands() class within the service, however I want to call these remotely. Possibly from a website or click once WPF application.
For this I have used a simple Tcp.Ip WCF example, and have verified it as working correctly.
This called OnStart()Private _serverCommands As ServerCommands Protected Overrides Sub OnStart(ByVal args() As String) Add code here to start your service. This method should set things in motion so your service can do its work.
[Code]...
It appears that in debug _serverCommands is Nothing when it should be running.How might I go about ensuring any command I execute through WCF communicates with the running instance instead of creating a new ServerCommand() instance??I haven't tried WCF before, so I might be hitting a dead end... however I'm sure its possible.
We can add class in class diagram and voila the code show up. What about the other way around. Say we already have a class. Can we add that to class diagrams?
I'm designing a .NET-Type at runtime by using the Reflection.Emit-Namespace. Currently, I'm about to generate a method which invokes an already existing method in the generating class:
I've been creating short test apps repeatedly to try to understand some of the concepts in VB.NET.For the most part it has been illuminating.I read Bucky's .NET knowlegebase tutorial on passing objects as parameters to newly created forms. He shows how to create a new class that inherits from the base form class and define a New() method with parameters Extending the concept I thought about doing the same thing with a form that was created at design-time (In this case Form2).
Base class has one field to hold numeric balance value. With 2 methods that accept arguments for adding and subtracting the new input calculating new balance. Sub class has four fields dates, transaction, memo and amount.I have a deposit form, and withdraw form. Each time one transaction is entered it creates an object with sub class fields, then adds to the account collection. My problem is not understanding how to call the deposit/withdraw method and pass the current transaction amount back to the base class to alculate the new balance. Does anyone have any links to information/tutorials on how to perform something like this? As you can see with my code I have tried various different approaches without any success.
Public Class airplane Private var_num_seats As Integer Private var_num_engines As Integer
[code]....
Obviously, I don't wish that the class Glider has the method "start_engines" neither the property "num_engines". Otherwise, other child classes may have. How can I supress these property and method in child class, not just ignoring (if I can)?
eg: dim classobj = xyz("CLASS_NAME") ' where classname is a valid class name and dynamically raising a known method of that class on that newly created object or class reference.
I found what i was looking for on this old thread but I don't know exactly what to do woth it. The code given by Tall Dude seems to compile fine except for two errors..
I'm writing a set of unit tests for a large, complex class called ImageEditor from a piece of legacy code, where image processing and GUI functionality isn't strictly divided. One of the methods in the class, BaseImageChanged, seems to be concerned entirely with how images get displayed and should be disabled in my unit tests to avoid unnecessary complexity. The test project is in C#, and the original code is in VB; my idea was to create a Decorator for the class in C# and then hide the method behind an empty one that does nothing. However, when I try running the unit test, the VB code keeps referencing the old BaseImageChanged method as though the replacement didn't exist. Here's what I'm doing:
I still can't understand classes in VB.net and I fell myself like a child.. I have found on MSDN example:Almoust everything is clearly, but DataGridView1 is created in this code in programm. If I have already DataGridView1 that created in designer - how can I override it events and ground it on other class?
I want to open an existing VB class file, add a few properties and close it again.
Simple enough, I thought: Take the CodeDom, a VBCodeProvider, parse the code (using the Parse-method), then identify the location where I want my stuff added (doubtless using some nifty LINQ expressions), add a bit of code and then have it generated and here we go.
Now I see that Microsoft apparently added the Parse method only for the fun of it but never implemented it.
What's the story here? Can I only generate code from scratch? Is it not possible to load existing code?
I'm trying to code a class of RandomNumber. One of the class methods needs to populate a "List (Of RandomNumber)" ... which was passed as a parameter to the method ... with 10 random numbers between 1 and 50. DEAD SIMPLE :)
I have a VB.NET solution (call it S1) which produces a .vb file (say File1.vb) to be compiled and then included in another solution (S2). S2 is a console app which I want to run from a cmd prompt, not VS. My plan is to shell out from S1 to run a batch file to do the compile and then copy the .dll file, overwriting the old one in S2 (then I can run S2 in a separate operation). Here's the batch file for the compile:
Relating to another question I asked yesterday with regards to logging I was introduced to TraceListeners which I'd never come across before and sorely wish I had. I can't count the amount of times I've written loggers needlessly to do this and nobody had ever pointed this out or asked my why I didn't use the built in tools. This leads me to wonder what other features I've overlooked and written into my applications needlessly because of features of .NET that I'm unaware of.
Does anyone else have features of .NET that would've completely changed the way they wrote applications or components of their applications had they only known that .NET already had a built in means of supporting it?
It would be handy if other developers posted scenarios where they frequently come across components or blocks of code that are completely needless in hindsight had the original developer only known of a built in .NET component - such as the TraceListeners that I previously noted.
This doesn't necessarily include newly added features of 3.5 per se, but could if pertinent to the scenario.
Edit - As per previous comments, I'm not really interested in the "Hidden Features" of the language which I agree have been documented before - I'm looking for often overlooked framework components that through my own (or the original developer's) ignorance have written/rewritten their own components/classes/methods needlessly.
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.
Is there any way to add new properties to a control? For example, I'm using an "OvalShape" from Microsoft's Powerpacks, these are designated as "Cells". I would like to add properties to the class itself (if I had a physical class to edit) for different processes such as "energy level", "family number", "mutation", etc. General variables that are either Boolean, Integers, or etc. If there isn't a way to edit the powerpack class itself, is there a way I can use the ovalshape power pack in my own class and add extra properties to it myself?
I have a class called Player in the business layer of my web application.Player class has fields PlayerID, CategoryID and CountryIDA function in Player Class calls a function in PlayerDB Class in the Data Access Layer which in turn calls a stored proc which returns data for PlayerID, CategoryID (foreign key to Category table) and CountryID(foreign key to Country table) from the Player table.I now have a situation where I want to add Country Name and Country Image (url path) to the above call, returning the new fields from the Country table for each CountryID.My question is, do I add the country name and country image as additional fields to the Player class or do I have new classes called Country(BLL) and CountryDB(DAL) and a new stored proc?
I know this is possible, and it is probably something simple that I am missing... I have a fairly complex class to handle deserialization of an XML file. I wish to place a [class].loadfile method within the class. It looks something like this: Serialization decoration left out for simplicity...
[Code]...
The Deserialization is working just fine (that's my own code), but assigning the object value to Me is not correct. What I want is for an instantiation of this class to have a LoadFile method (similar to the XML class LoadFile method) - but I cannot figure out how to set the value of the class from within the class.
if I have several of these movable PictureBoxes added to a Form (Form1) and want to display a selection rectangle only on that PictureBox, that is just selected,then I think I should use a flag to mark whether a PictureBox is selected or not. The flag could be used in paint event to decide,whether the selection rectangle is to be drawn or no .To add a flag property to the new class is no problem. But how can I set the flags in all other existing instances of the class, when it is set to True in the selected PictureBox?
just wondering if it is possible to add a method to all forms in my project without having to do it on one form and Inherit all my other forms from that one