I have a class called Profile that has some simple properties and then it can have a collection of ProfileItem that again has some simple properties and then it can have a collection of ProfileItem (RECURSION). Now I am trying to generated a very simple save function using XML Literals that come with VB.NET (3.5).
I've tracked a recursion error down to one subroutine, So when my form loads, it populates some listboxes from a database; any one of these causes the error: ListboxQuery("select sculptname, sculptid from sculptures;", CloseSculptList, "sculptname", "sculptid") ListboxQuery("select distinct eventtype from events;", EventTypeList, "eventtype", "eventtype") 'etc, etc
And here's the subroutine (it's querying a MySQL database): Public Sub ListboxQuery(ByVal queryText As String, ByVal resultObject As Object, ByVal resultDisplay As String, ByVal resultValue As String) 'queries the database for a 1- or 2-column list of values to display in a listbox Dim myCommand As New MySqlCommand Dim myAdapter As New MySqlDataAdapter [Code] .....
The error is the standard recursion error: An error occurred creating the form. See Exception.InnerException for details. The error is: The form referred to itself during construction from a default instance, which led to infinite recursion. Within the Form's constructor refer to the form using 'Me.'
This is weird for two reasons: One, as you can see, the subroutine doesn't refer to the form at all, so I don't see how it could cause a recursion error, and two, I wrote this subroutine almost a year ago and it only caused this error last week.
I am trying to implement Selection Sort in vb.net using recursion. Problem is that I keep getting stackoverflow if the array I want to sort is 1000 elements. I can't find the problem. I don't know much about stack overflow or how to check it. From my research the problem could be infinite recursion but I check for that and exit the sub.Here is the main code:
Public Class SelectionSort Inherits DefaultSort Public Sub New(ByVal num As Integer)
[code]...
Everything should work as far as I know. It works on an array of 10 elements and an array of 100 elements.
Is it possible to make this function iterative or must it be recursive?
The Function traverses a grid of x length and y height. At each point in the grid, it checks all of it's neighbors to see if they are valid, meaning they exist in the grid and haven't been used yet.
The function works in it's current form but I was wondering if an iterative version would be more efficient.
PathManip is a Stringbuilder, stores the path currently being manipulated. PathQueue is a List(Of String), stores all paths yet to be traversed.
IsPathAlreadyUsed is a boolean function that checks whether or not a specified point has been used in the current path.
Sub FindNeighbors(ByVal coords As String) Dim x As Integer = CInt(coords(coords.Length - 2).ToString) Dim y As Integer = CInt(coords(coords.Length - 1).ToString)
I have a situation where I have a hierarchy. I'm trying to use LINQ to get all of the items throughout the hierarchy as opposed to For Each loops. I spent some time looking for examples, but most where C# using lambdas, and I'm not quite sure I understand it. I'd like to try to get all of the Items for a specific system, the levels of items could be n-levels deep.
I got that little function(I changed the name of variables)
Private Function everythingLinked(ByRef myClass As cls, ByVal found As Boolean) As Boolean If Not found AndAlso myClass.checked = False Then myClass.checked = True
[code]....
I want to rewrite it so it would only be loop and no recursion and I'm currently lost?I'm passing a class to this function(with a starting value for found as false) to know if it is linked to the middle of the tree. The class got an array with a maximum of 4 link to other class and it can be circular(this is why I have a checked_link boolean).It does the recursion until there is no more link(return false) to check or until it find the middle link(return true).
edit?for an example, this
in pos 0 got link with 1 in pos 0 got link with 6 in pos 1 got link with 0
[code]....
middlepoint would be pos 15 the code above can prove that every position can be linked with the middlepoint so initial arg would be
I developed an app, tested on few computers and all seemed fine. But now, some people suddenly get an error, which I can't repeat on my computers. Part of the exception:
** Exception Text ** System.TypeInitializationException: The type initializer for 'NumoABC.functionsBurtuSummas' threw an exception. ---> System.InvalidOperationException: The form referred to itself during construction from a default instance, which led to infinite recursion. Within the Form's constructor refer to the form using 'Me.' at NumoABC.My.MyProject.MyForms.Create__Instance__[T](T Instance) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 180 at NumoABC.My.MyProject.MyForms.get_MainForm() [Code] .....
The If Me.Created = False Then is because while the form is loading, some events fire the updatePersonDataHandlers() sub, but I don't want it to happen until form is fully loaded. In the module functionsBurtuSummas line 2 Module functionsBurtuSummas Private f As MainForm = MainForm I have many modules who work with the MainForms' controls, so I use a private variable f to refer to the MainForm.
I've got a menu with checkable items that appears on two different forms, and I'm making sure the two forms always have the same check states, so Form1 would have something like this:
Private Sub mnuWarnings_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuWarnings.CheckedChanged 'when one of these is checked, the other should also be
[code].....
But that yields this error:
An error occurred creating the form. See Exception.InnerException for details. The error is: An error occurred creating the form. See Exception.InnerException for details. The error is: The form referred to itself during construction from a default instance, which led to infinite recursion. Within the Form's constructor refer to the form using 'Me.'
There definitely aren't any references to Form1 within Form1.It only occurs when I use CheckedChanged--if I use mnuWarnings.Click, it works fine. And it only occurs in Form1 (the main form); CheckedChanged works fine on Form2.
I'm trying to put together a quick example for another thread about treeviews, and I'm getting a problem when I have a recursive routine, getting the message.
Quote:
There is already an open DataReader associated with this Command which must be closed first.
I'm a tad confused as I am explicitly creating a new command every time through the loop, so I'm not sure (unless its something ADO is doing behind the scenes) how the datareaders higher up the tree are interfering.
Here's my code :
Private Sub SetupChildren(ByVal ParentID As Integer, ByRef ParentNode As TreeNode) Dim MyCommand As New SqlCommand("SELECT * FROM Groups WHERE ParentGroup=@ParentGroup", m_myConnection)
[Code]...
Obviously I could close the data reader down before calling the next level of recursion but it would prevent the code continuing the loop at the current level when it had finished processing children.
is there a way to enable IntelliSense for XML literals in VB9 (VS 2008)?The ideal source of IntelliSense is an XSD document, but I can use anything else format to do it.
If it's possible, it would be a lifesaver since I can't use XElement and XAttribute to add the nodes manually. We have multiple templates and they frequently change (edit on the fly).
If this is not doable, can you think of another way so that I can use templates for the XML?
I am using XML Literals and Linq to XML to read/write data to an external system.[code]The client now wants to put the url in a parameter table so the table can change to point to a test server or a real server. I assume that I cannot put a variable in my Imports statement.So how to I access the correct URL from a variable?url...
I have two forms. A main form and then another form that you can change settings in. Now when I click on the menu item to get to the settings form I get this error. "An error occurred creating the form. See Exception.InnerException for details. The error is: The form referred to itself during construction from a default instance, which led to infinite recursion. Within the Form's constructor refer to the form using 'Me.'"I've tried these codes.
frmSettings.Show() Application.Run(frmSettings)
those didn't work so i tried these
dim settings as new form = frmSettings settings.show() dim settings as form
[code]....
and those didn't work. I'm using visual studio 2010 Pro.
I have a program that has a large set of classes in it. A certain incident (I won't call it an event, yet, as that has a specific meaning that will cause trouble later) needs to a relatively small subset of these classes a question. The subset of classes will need to respond to the question, but for it to be able to do so, the classes may first need to ask a similar question of the same subset, which may prompt yet a further question, though this recursion will never go more than three or four levels down. Since only a small subset of these classes will participate in the questions, while the majority will never participate, and since all of these classes are virtually identical, and I can know at design time whether any given class is part of the subset or not, an event is appropriate. The main class can raise an event, and those classes in the subset can handle the event, while those classes that are not in the subset won't handle the event. Furthermore, any of these classes can raise the event again with different parameters, as needed. Thus far, an event appears to be ideal.
The problem is this: As a result of the event, each class will need to add one or more strings to one of two lists. Event handlers can't return anything, so I can't be using the return values from functions to populate these lists.
Two options appear possible:
1) Include the two lists in the event arguments.
2) Have the two lists be accessible to all classes, and don't pass anything around.
The second part of the problem is that the event is effectively a question being asked of each class, and no action can be taken until each class has responded. If I simply raise an event and let each class respond, can I be certain that all classes that should respond have? An alternative solution would be to have each class expose a method, and call these methods for each class in turn. By doing this, I could get return values, but I would have to call the methods for ALL the classes, not just the subset that actually cares (the classes are all different types, but they all implement a common interface, and are added to a List (of ) that interface, so I can iterate through them all without much difficulty). So, the event seems more efficient, but adding a function to the common interface for the classes is the approach most certain of being a solution.
I'm using the following function to brighten up color values (it's a lambda in my code, but that shouldn't make a differende):
Function ReduceDistanceTo255(ByVal i As Byte) As Byte Return i + (255 - i) 2 End Function
It won't compile, since the compiler interprets 255 and 2 as integers rather than bytes, making the result of type Integer. Unfortunately, there is no Byte type character, so I cannot just write 255B or something like that.There are a few obvious workarounds to the problem:
Function ReduceDistanceTo255(ByVal i As Byte) As Byte Return i + (CByte(255) - i) CByte(2) End Function
and
Function ReduceDistanceTo255(ByVal i As Byte) As Byte Return CByte(i + (255 - i) 2) End Function
[code]....
The first one is just plain ugly and hard to read, because every literal needs to be CByted. The second one performs calculations in integers and then converts the result to Byte, which is OK, but not as elegant as a pure-Byte operation. The third workaround doesn't require CBytes, but it's drawbacks are obvious.
In VB.NET I can easily embed strings into XML literals using <xml><%= "my string" %></xml>. How can I embed an XElement instance? I know I can use methods on the XElement, XNode, etc classes, but I'd like to do it in the XML literals if possible.
I am constructing some XML using XML literals. I have a function which returns an XElement.
Function RootElementFormattingFunction() as XElement Return <Root Data="foo"/> End Function
In reality it is a bit more complicated than that, but it is called from several places. Now I have linq sequence which generates a set of nodes which I want to make children of the XElement returns
I'm trying to use the builtin XML literals feature to create/read xml files using my own schemas, but I don't see a way to cast an abstract XElement from a base type to a more derived type.The schema/xml below shows in general what I'm working with, but using XML literals only allows me to use the base type in the IDE, so the xml below is treated as a collection of elements of the base type, instead one of the base type and one of the derived type.
Is there any other way of removing a specific tag other than looping through every tag and checking a certain value? I would assume this could become of timely process if there are many tags.
As basic as this is, it took me a few minutes to figure out, so wanted to share with the rest of the community to avoid anyone else from wasting their time.
I am attempting to generate the following XML string using VB.NET XML Literals
<Books> <Book Name="The First Book" /> <Book Name="The Second Book" /> </Books>
[Code]....
But the compiler is complaining about the quotes that are supposed to surround the attribute value. I tried using single quotes, two double quotes, nothing works.
My problem is that I want to include control structures in the embedded XML. Specifically, I want to include or exclude an entire element (not just its contents) based on a boolean expression. The question extends to other control structures as well though.
I'd expect the <% %> syntax to support inling of code but that doesn't seem to function in VB.net's implementation (as opposed to the <%= %> for inlining the result of an evaluated expression, which does).
Here's some very simple code by way of example only.
Public Class Foo Private bar As String = Nothing Private baz As String = Nothing
[code]....
I'd much prefer to use the format of getXMLBad() if possible. In this short example it doesn't seem critical, but in much larger examples, the inlining of the logic is more readable and maintainable than the "assembly" style in getXML(). This especially true when the logic is in the middle of large block of static XML and when coding to a very strict or complex schemas.I'd be interested in the capability to extend this to Looping constructs as well.
Currently am working on a project that requires me to create some XML for use with a graphing plugin. I'm using XML literals and LINQ to SQL as follows
Dim x As XElement = _ <chart caption='Aantal aanvragen' xAxisName='Dag' yAxisName='Aantal'> <%= From d In dailies Select _
I have a masked textbox on my form for a phone number. I want to store its value in my Database without the literals as the database field for that phone is only 10 characters long. How do I store this value in the database field without any literals.
been working on a large scale project and Iow looking into the document print engine for the application. been a while since Ie built an app that retrieves data from the database and outputs to Word. I generally always used the mail merge feature of Word but after reading the link above this seems far easier.
I have an XElement that I need to create via dynamic xml literals/embedded expressions and I need it to inherit the default namespace. This doesn't appear possible though through everything I've tried. how to make this work?
For example
Imports <xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> Sub CreateXAML() Dim obj = "Rectangle"