I've seen people discourage other from using nested classes, because the make things more complicated and are evil and whatnot.But I want to know what possible justification there would be for using a nested class and if there are any possible benefits for using them(or structures for that matter).
code For Each item As Reflection.FieldInfo In GetType(NameSpace.ClassWithNestedClasses).GetFields rtfAppend(item.Name & ":" & Tab & item.GetValue(Me)) Next For Each item As Reflection.PropertyInfo In GetType(NameSpace.ClassWithNestedClasses).GetProperties()
[code]...
which gets me the simple string vars and properties of my top class, but how can i apply this to loop through all sub classes and get there vars and props?
I have put together the following code to illustrate the problems I've been struggling with:
Public Class OuterClass Private _OuterProp1 As Boolean = False Public Property OuterProp1 As Boolean
[code]....
I need to be able to refer to outer class properties and variables in an inner class, and I need to have a variable in one inner class set in a different class. I've tried Public, Private, Protected, Friend and all kinds of combinations of them, and I can't figure it out.
I have two classes, one nested in the other. [code]Neither "Name" or "ID" are unique between operations and records.I wish to construct a dictionary using LINQ = Dictionary(Of String, Of List(Of Integer), whereby the keys are uniqe examples of Names in my collection and the values are the collective set of distinct IDs that are associated with those names.
How can I structure my classes so that the user interfaces though a single class while the supporting classes are hidden from their view? I think its best understood in an example:
Public Class MyInterface Public Economic as EconomicClass Public Sub New() MyBase.New()
[code].....
So you might ask why am I even separating them? It's strictly for others who will be working with this interface. I need to funnel them though a logical structure:
This way everything is already handled for them in the background and they only need to run the method they need. I don't know if I can have it both ways in VB.NET.
I have a nested class, let's call it class1 and it has class2 inside it; VB.Net eg:[code]
1) How can I define X number of Class2 objects[let's call it: Node(x) array]** with NEW() subroutine called?' this raises error: dim cls2(n) as new class2 end sub.
2) How can I return actual number of Node() array? [code]Outside my class in main project I define cls1 object:[code]Now an array of class2 is created inside cls1.
3) Now,How can I access All of them[node(x) array which is created inside cls1] with all properties and methods available?
I remember I wrote a ProcessManager class with this functionality in .net 2003, nearly 4 years age, I don't have the code now.
I have a MDI project that has a parent and several children forms. In some of the children forms I would like to make one of the forms to be a parent form with children. On this child form I wanted to make a tabbed MDI, which I can do, but I have found out that I can't make a child form a parent, from what I have found.
Is there any way to get around this? (As in nested MDI forms.)
I am trying to code something with nested for loop with the following format:
[CODE]...........
However when the program hits the last value of 'For loop 1', the nested for loops seem to only trigger once instead of the number of times that i specified.
Private Sub populatedgv1() 'setup temptable to store Server data Dim m_table As New DataTable
For the time being I have been using a Structure to store "people" (their name, gender, age, etc...), because I really love to refer to something like Mike.name or Caroline.age, so I could simply put Caroline.age += 1 anywhere in the code and here you go, Caroline is one year older. No more simpler.But because of how inflexible (compared to Classes) Structures appear to be, when I needed to iterate through all the instances I was forced to use a list or dictionary so I could use a FOR EACH ... NEXT block. That was resolved by you people in the previous post, but I'm having the problem that I couldn't use the elements of the list to change the original instance of the Structure proper... I mean, if I code something like this...
For Each thisperson As Person In peoplelist If thisperson.name = person_selected Then 'person_selected is the SelectedItem.ToString of a listbox[code]....
Well, I thought that thisperson.teamleader and Mike.teamleader were going to be equivalent (when the IF statement was true, that is) but that doesn't appear to be the case. So right now I'm really hating Structures...But when I look into Classes... well, they have more flexibility, yes. You could construct a FOR EACH block without any other trick like the "on-top" list, and that it's very useful indeed, but (a big "but" IMHO) I lose that NICE feature that makes possible to write the name of one of them instances like Mike.age or Caroline. kills
I mean, if I wanted to add a year to Mike, well... there is no "Mike" in the first place. A "Mike" string could be a property for the class, but I cannot (or know) magically refer to him with the ease of a Structure, so when I want something so simple as Mike.age +=1 ...well, with a Class I'm simply clueless to how locate him and change ANOTHER property of him.I suppose I am doing something very wrong, because I cannot believe VBasic could force on you those two extreme philosophies...:
Classes = +flexibility -usability ???
Structures = -flexibility +usability ???
What I want to do is SO simple that I cannot believe I need to choose between the two.
I need some help with how to organize classes in VB.NET. I have a class called parent with methods for adding, deleting etc. But I also need a method that returns a list of all the parents, a list with parent objects. Where do I put this method? Do I put it in the parent class or do I need to make another class called parents?
Public Class Form1 Dim CharList As ArrayList Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click CharList.Add(TextBox1.Text.ToUpper)End Sub Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
For a class project (online course, no instructor handy to get a quick reply from -_-) we are to write a short program using classes and OOP to roll a pair of 6-sided dice 1000 times and count the number of times the total of the two dice is 7. Easy enough, and I've read over a few examples that people have written, but they don't seem to use OOP. I'm not asking you guys to do my homework for me, but I am terribly lost when it comes to using OOP. So far I understand that I should be using a Random() class object to determine the roll itself, and then maybe load each roll into an array and use a loop to check if each element is 7 or not, and then increment a counter? How do I set the range of Random() so my dice rolls are representative of a 6 sided die? It's all a bit overwhelming and I'm not sure what I should do next.
What are the best ways you guys recommend to search the MSDN Code Library. I know there have been several instances in searching for ways to do something, doing a long workaround, and finding out later that there was a built in class that handled the problem that I was working on much simpler.
So what are some of the ways you guys use to find tools, classes, etc. when coding. Or are you just that awesome already.This is kindve just a general tips and tricks question. Sorry if Im in the wrong forum mods.
Is it possible to have multiple classes in a namespace and be able to reference the functions within the clases if the Major class is instaniatated from another class?? for instacnce:
Namespace Database Public Class Data Public Class Prepare
I have a MDI application and a very complicated class there which populates its properties from a dataset derived from an external database. Each form, including child forms have to be able to access that class and use its properties thorughout the whole session.I don't know where to 'preserve' these property values within the application. I kmow many books etc. suggest not to use public variables but I really can't find a way to solve this other than to use a public variable (which is a list(of my custom class) in this case. I have a separate class called PublicItems.vb and declared there my public variable as
Public Shared secuniverse As List(Of myCustomClass)Is there something wrong with the syntax because if I try to use the variable secuniverse in my main application class, I get the following exception:'sectoruniverse' is not declared. It may be inaccessible due to its protection level.
I've been trying to do this for a while now.What I intend to do is that when I load a webpage in a class, i raise event to my form that the data is recieved.
I am having this strange thing happen where I have a Module that contains multiple classes in my project. In the Solution Explorer, the module shows up as a Windows Form and if I double click on it to open it, it tries to open the Form Designer. What could be causing VS to think that it is a Windows Form instead of a module?
Searching the internet finds no less than 700 different ways and opinions to accomplish what I'm trying to do, and I would just like to know the simplest, most bullet-proof way possible.
[Code]...
I simply want to extract the string "bar," which is inside <hostName></hostName>I can do this easily enough with simple string functions, but I'd like to do it with one of the .NET XML classes/methods.
I have an outer listview and inside its itemtemplate an inner listview. Each has its own SQLDataSource. A Id field from the outerlistview works as a select parameter for the second listview.
When stepping through with the debugger it works perfectly, unfortunately the rendered page only contains data from the outer listview. It appears the databinding of the outer listview fires and renders the page (including the inner listview) before the codebehind can provide a where parameter to the second listview. The aspx page is below.
I am using nested datalists to display hierarchical data. In the nested datalist i want to be able to bind to a property that belongs to the object that the parent datalist is bound to.