As a learning experience I decided to try and implement the Shunting Yard Algorithm(string calculator) using OOP. It was successful for as far as I took it, but it had one flaw. In order to get the stack to be accessible from the operators I had to declare it as shared, which meant that all versions of the calculator shared one stack. This very short piece of code illustrates what I came up with and the "flaw". [code] How can I maintain the functionality of anOP.add1 without declaring "something" as shared?
I recently installed visual studio 2010 and am using visual basic.The problem I am having is that some operators do not show up within the editor. For example the code line below test = 3 + 5 - 6 / 7 * 4
only displays
test 3 5 - 6 / 7 * 4
the = + operators are not visible although they are there since the program will work as intended....and if I open up the .vb file in notepad everything is there. It just won't display within Visual Studio.
I want to place the arithmetic operators in an array so I can randomly select one at a time. I am not sure how to declare and initialize them so that I can use them in an equation.
Did anyone else read this article under Visual Basic News? I thought it was a very bad treatment of the subject. I especially don't like articles like that when the code they post relies on Option Strict Off.
According to MSDN The And operator can act as a bitwise operator OR a logical operator.The only way to know if it is used as One operator or another is, If it is on the right side of an assignment operation? for example x = 3 AND 5. I cannot find any other instances where the bitwise operator would be used instead of the logical operator, are there?
Can I store the common operators such as '>', '<', '+' etc., in a variable and then use it when required.
[Code]....
so here instead of directly using > and +, Can I use the variables OP1 and OP2 somehow. May be I can put the entire string from "If..... NUM1" in another variable as text string and then execute that variable.
Using 2 objects of the same type, I'm trying to implement < and >, but I can't seem to find any authoritative source on what to do with either or both being Nothing. In other words what the accepted practice or MSDN suggestions are.[code]Accessors is my canonical method for centralizing an enumeration of the properties (all are decimal)return false for both if either is Nothing?I found a comment, but can't seem to verify or validate it that A null object is always less than a non-null object..
I have a weird situation. I have a C++ code that overloads the +,-,* operators and exports them in a .DLL file. Now, I want to import those overloaded operators from within VB.NET code. So it should be like this:
<DllImport("StructDLL.dll")> Public Shared Function Operator +(ByVal a1 As A, ByVal a2 As A) As A End Function
So what I'm trying to do above it just import the lovely overloaded operator + from the DLL.Note that the operator is already overloaded from inside the DLL, so should I import it as a Function or as an Operator like this?
<DllImport("StructDLL.dll")> Public Shared Operator +(ByVal a1 As A, ByVal a2 As A) As A End Operator
The overloaded plus operator is supposed to add structs. So the DLL is programmed to work on structs (C++) and I want to import it in VB.NET to work on Structures.
I have a custom class that simply contains a public variable X.Let's say I have two instances of the class, A and B.If I execute an assignment operator, such as:A = B then I want A.X equal to the VALUE of B.X.But, I'm pretty sure that this will just assign B to the variable A.Assigning pointers, in C++ lingo.I looked in the VB.NET docs, which state that "The operator can be overloaded only as a relational comparison operator, not as an assignment operator."
In C# you can use the implicit keyword to define an implicit user-defined type conversion operator.In VB.NET you can define a CType conversion operator that will explicitly convert a user-defined type into another type.Is there a way to declare an implicit conversion operator in VB.NET?
I'm having the exciting task of finding out about VB.NET's <> and Not operators. Not - I'm assuming by my small use of it - is the functional equivalent of ! in languages such as C# and <> being equivalent of !=.
In VB.NET a common problem is doing Boolean expressions against objects that don't have a reference, it appears. So if we do If Request.QueryString("MyQueryString") <> Nothing Then This will actually fail if the query string doesn't exist. Why, I don't know. The way that it's done by older coders is as follows: If Not Request.QueryString("MyQueryString") Is Nothing Then
And this tends to work. To me they're functionally equivalent though operators tend to do different comparisons dependent on certain factors such as operator precedence, why it doesn't work in this case however, I do not know, and neither have I found any relevant material. I ask this as I'm having to write standards documentation and we're determining the use of either the Not or <>.
I have to perform calculations dynamically in ASP/VB.NET (Possibly SQL Server). Something like this: Dim var1, var2 as Integer Dim Optr as string var1 = 15 var2 = 25 Optr = + MyResult(var1, var2, Optr) And MyResult should equal 40. How can I do this?
I have a class that implements an interface. Other objects will get an instance via a method like:
Dim AU1 as IAUC = GetAU(<some GUID>) Dim AU2 as IAUC = GetAU(<some other GUID>)
What I would like to be able to do is this:If AU1 = AU2..The parts of the class that make up the interface could be equal when the rest of the class is not, and the equality of the interface objects (if you can call them that) is complicated. Several fields have to be compared in odd ways.One option I have is to just add an Equality method to the interface, which would work, but I would rather overload the = and <> operators. As far as I can see, you cannot overload operators as part of an interface, but I was hoping that I had overlooked something.
I have a simple routine to find the next object based on a name property in an un-ordered collection of objects. I go through the collection and collect all the names in a List(of String) adding any names that are > my current name, which should give a list of everything that comes after the current key. I then sort the list using the default .Sort() method on the List(of String) and take the first item in the list, which should be my next item. I do the reverse to find the previous item, add all items < my current name, sort, and take the last item in the list.
However, this method skips over some items. For example I have items named 1210, 1210-ADA, and 1210_ADA_DB. Using this method, getting the next item skips the middle item 1210-ADA and finds 1210_ADA_DB, but finding the previous item seems to work.
Given that a typical coding mantra is "Don't induce side effects in method calls." and that the only reason (that I know off - please enlighten me if I'm wrong) to not use short circuited operators is when you depend on the side effects of a method call in subsequent code. Why isn't the default operator in languages like C# and VB.NET not a short circuited version?
Of the 51 Standard Query Operators (of which only 42 are actually query operators), only 24 are directly supported by Visual Basic 9 and just 11 by C# 3: Query Expression Syntax for Standard Query Operators.In many cases, query syntax is arguably more readable than the equivalent method syntax, especially when transparent identifiers are involved. However, that readability breaks down if you have to combine queries and method calls.So the question: What query operators, current or hypothetical, would you like to have your language of choice support in query expression syntax?
Is it possible to overload the array/dict access operators in VB.net? For example, you can state something like:[code]And that works just fine. But what I would like to do is be able to say:mydict("Cool guy") = "3"and then have 3 automagically converted to the Integer 3.I mean, sure I can have a private member mydict.coolguy and have setCoolguy() and getCoolguy() methods, but I would prefer to be able to write it the former way if at all possible.[code]
Is there a way you can do this ? I would like to have a collection class of T that would be able to do addition, substraction on the T type. I would like to keep T generic instead of having couple collections with the same code, but different types. How would you constrain the generic T?
Example: I would like to define a Collection(of T as IDoMaths). I wouldn't like to create my own integer etc classes with named methods to do the operations, because I think it would be slower. This part of the code is actually called very often and tends to be the bottleneck in performance.
I need to create a tiny calculator using the basic operators of Addition, Subtraction, Multiplication, and Division. My professor hasn't really covered much of this, so I'm not to sure how to create it.
In your actual programming experience, how did this knowledge of STACK and HEAP actually rescue you in real life? Any story from the trenches? Or is this concept good for filling up programming books and good for theory?
What I want to know is that in VB.net is it possible to get a stack overflow, and if so how is it caused. What I mean is, what sort of written code would cause a stack to overflow.