How To Save Object Hierarchy

May 5, 2010

I have created a set of classes that represent an hierarchySo when I reference like this:

Dim alldeals as deals
alldeals.Deal(5).DealSlot(3).SlotType= "SomeType"
alldeals.Deal(5).DealSlot(4).SlotType= "SomeOtherType"

[code].....

View 3 Replies


ADVERTISEMENT

Flattening An Object Hierarchy Using A Shim Class - Initializing Derived Object Properties From The Base Object?

Jul 10, 2010

I am somewhat new to object oriented programming and am attempting to flatten a Linq object hierarchy by using a shim class.how to initalize a derived class with property values from a base class?I have two objects, a base object with about 100 properties, and a derived object which inherits from the base object and adds a few additional properties beyond those of the base object. My simple constructor creates the derived object, but I am looking for a way to initialize the derived object properties with values from the base object.Right now I am using reflection to iterate over the properties individually and I suspect there may be a better way. The following example shows my shim class constructor for the derived class, and two properties:

newProperty1 - a new string property of the derived class

flattenedProperty2 - a new string property of the derived class, copied from a 2nd-level object of the base class

Code example:

Public Class derivedObj
Inherits baseObj
Private _newProperty1 As String[code].......

Is this the correct constructor approach to flatten the object hierarchy using a shim class? My second question relates to initialization of properties in the derived class. The constructor above creates the derived object, but what is the best way to initialize the derived object properties with values from the base object? The following code uses reflection to iterate over the properties individually, but I suspect there may be a better way.

Code example:

' property names are in the string array fieldNames

'baseObjQuery is an ienumerable of baseObj

'derivedObjList is a list of derivedObj[code].....

Is there a simple way to initialize values for the properties in the derived object based upon the values of the common properties in the base object?

View 7 Replies

Object Hierarchy For Charting?

Jan 27, 2009

I'm looking for advice to make my code efficient in terms of execution speed and memory usage. Basically, how to lay out my objects. The program displays parts of several data series in bar- or line- charts, as well as calculated series based on these data series. The key user input will be to change what part of data series to look at, and that input should trigger instant chart update, with minimal lag.

[Code]...

View 10 Replies

Want To Eliminate One Level In Object Hierarchy?

Jun 7, 2010

Not sure how to do thisI have a hierarchy:

Deals at the top
Deals is a collection of Deal
Deal is a collecton of DealSlots

[code]....

View 3 Replies

Object Reference Not Set To An Instance Of An Object: VB Save Webpage?

Jun 15, 2010

Okay, so I'm using this code to save a webpage to a file:

Dim myWebClient As New System.Net.WebClient
myWebClient.DownloadFile(mainbrowser.url.tostring, _
"C:/currentpage.html")

[code].....

View 9 Replies

How To Program The Hierarchy Like This In .Net

Mar 30, 2011

I am a beginner for using VB.NET. I have a problem in which we have several "Program", each "Program" has N "group", and each group has N "unit", shown as follows. i need to link "Program" and the corresponding "group" and "unit" together. First , the properties of lower layer depends on upper layer's properties. Second, If i delete one "Program", the cooresponding "group" and "unit" will be deleted as well.

[Code]...

View 2 Replies

Event Won't Come Through Class Hierarchy

Feb 2, 2010

I'm writing a Windows Forms application in VB.Net 2008, .NET Framework 3.5, and I am trying to handle an event created by a class that get's instantiated several times throughout the program. The thing is the events gets fired in the Functions class, but nothing's happening in the main class.I tried to change the called class by instantiating it in the beginning of the main class, by using 'WithEvents testEvent as MTO_Tool.Functions = New Functions' but that also didn't work.

Code:

' The main class:
Public Class MainScreen
WithEvents testEvent As MTO_tool.Functions
Private Sub test() Handles testEvent.SaveChanges

[code]....

View 1 Replies

Making A Shape Hierarchy?

Apr 10, 2012

I am working through my Visual Basic Book 2010 book and came across this Program example:Create 3 classes that inherit from a base class named Shape. The Shape class has an instance variable that is the name of the shape and also a CalcArea() function that must be overridden by each subclass. You will need to create the following 3 classes and use the formulas provided to calculate the areas.

Square � Area = sideLength * sideLength
Circle � Area = pi * radius * radius (use Math.Pi for the value of pi)
Triangle � Area = � * base * height

Each subclass should have a constructor that you use to set the name and the attributes required to calculate the area with. Each subclass should also override the CalcArea() function that is provided in the base class Shape. They will also need to implement the toString() method that will print out the shape name, any attributes (ex: sideLength), and the area.It also includes the Shape base class. You will need to add the 3 subclasses and add the appropriate code.

View 5 Replies

Getting All The Parent Hierarchy Until Reaching A Certain Type?

Feb 3, 2009

I could put a Textbox in a Panel then that panel is placed in a TabPage, how do I go out going through the hierarchy of the Textbox parent until reaching the TabPage? My purpose for this is if I want to focus on a Textbox then of course I would have to also select the TabPage where it is located, is there an easier way than what I am planning to do?

View 3 Replies

Regular Expression: List Hierarchy?

Jan 6, 2010

I am working on an opening search screen for a program that grabs information on a file for the user. Subfolders are defined by periods so some possible files include

FolderA.SubFolder1.SetupX.txt
FolderB.SubFolder2.SetupY.txt
FolderB.SetupX.txt
FolderA.SubFolder1.SetupZ.txt

When the search button is clicked all of these are populated into a list box currently using the following function's

[Code]...

The problem is that subfolders will continue to be created with unknown names. I'm thinking I need to use some sort of loop that counts the number of periods and then compares the directories using some sort of negative lookahead to group them. Im still unsure how I'll make it so Clicking Setup Y and hitting OK will be able to maintain that I am opening FolderB.Subfolder2.SetupY.txt and not just SetupY.txt

View 4 Replies

Class Hierarchy - Data Design In An RPG Game

Aug 10, 2010

how to organize the classes within my RPG project that I'm making. I've tried to implement a battle system but I am not comfortable with my initial results. This is the basic layout I currently have for my classes. [Code] clsCharacter contains statistics pertaining to one character, including magic available to that character to use. Also includes what weapons that character has equipped. clsTeam contains multiple clsCharacter, as well as a list of items that each clsCharacter in the team can use. clsBattle contains two clsTeams. One team is the player and the other is the computer. Now, this is a wonderful way to organize data. However, I see limitations with this approach. For instance, to pass data from Battle to Character, it has to pass through the team class and vice-versa. Plus, if I use Properties, it transfers data as ByVal instead of ByRef, so I cannot guarantee that I'm editing the original and not a copy of the passed object (IIRC)

In addition, I feel it is just messy code to include methods within the clsCharacter class that invoke this: MyTeam.MyBattle.DoAction(). Plus, the clsCharacter might not even be in the battle at the time - I don't won't to bog down that class featuring code that is exclusive for battling when I also need to be concerned about moving around the map, saving/loading data, etc. So, any suggestions? Right now, I'm burnt out of ideas. One idea I have so far is to include a function for the clsCharacter that exports a list of all possible moves the character could make, and if the character is CPU choose the most optimal one, and if Human than wrap it up in some nifty GUI so they can choose what action to take. But at the same time, how do I use that information within the context of the battle?

View 2 Replies

Show Folders / Files Hierarchy In TreeView

Mar 5, 2008

Any code snippet they could post that will take a specified folder & show the files & subfolders hierarchy in a TreeView?

View 11 Replies

C# - LINQ To SQL To Query Parent And Count Childs In Hierarchy?

Dec 8, 2010

I'd take both C# and VB.NET suggestion.I'm using LINQ to query data. I'm trying to query the parent and count the child tags.Here's my Tags table column:

TagId (int primary)
TagName
ParentId (int Allow NULL referred to TagId column)

Here's some sample data:

[Code]...

View 3 Replies

Entity Framework 4.2 Table Per Hierarchy Group By Discriminator?

Dec 7, 2011

I am working on a project using an EF 4.2 code first model. This model contains a TPH inheritance structure for products. I need to group the polymorphic results of this inheritance model on the discriminator and am running into some issues.

The entity framework does not expose the discriminator to complete this grouping. My first question is can I get direct access to this discriminator? My reading and experience is telling me no, so I came up with this solution that sort of works. It is not performing well and I am not happy with how it will need to be maintained.

My classes look something like this (simplified):

Public MustInherit Class Product
<key()>
Public Property ProductID as integer

[Code].....

Also, this can give me easy access to shared properties (Name) but now I don't have many options to cast these into their real type, maybe a select case around TypeName.

View 1 Replies

Inheritance Hierarchy For Class Quadrilateral / Square And Rectangle

Sep 30, 2009

I have to write an inheritance hierarchy for class Quadrilateral, square and rectangle. Use Quadrilateral as base class of the hierarchy.

So for I had this:
Public MustInherit Class Quadrilateral
Public Function getName() As String
Return "Shape"
End Function

View 1 Replies

Visual Studio 2010 - Creating Hierarchy Of Files?

May 23, 2012

I'm trying to create heirarchy of classes in vb.net. I was able to achieve it in csharp by using the following tags in .csproj

<Compile Include="ClassA.cs">
<DependentUpon>ClassB.cs</DependentUpon>
</Compile>

Below snippet in the solution explorer would be as follows

I need to achieve the same in vb.net.

I'm new to vb.net. Can anybody tell me the alternative of <DependUpon> attribute used in .csproj equivalent in .vbproj. For some reason, this attribute seems to be ignored in the .vbproj even though it is displayed in the visualstudio2010 intellisence.

View 2 Replies

Class Hierarchy - Data Design In A RPG Game Where Classes Overlap?

Aug 19, 2010

This is a followup to the question I asked here:

[URL]

I understand the answer in the post above, which is absolutely amazing, by the way. It's about implementing interfaces with a class. However, what if a class needs to share features with another class?Yes, that class can an Interface. However, let's use this sample definition.

[code]...

Or, in other words:An equippable item can perform acts outside of its typical usage of a shield or weapon. But not all items can act as a sheid or weapon.I mean, I could create a class that implements IWeapon, IShield, IMagic, IUseableItem, etc. But there should be a better way than returning NULL when those interfaces are called.

View 2 Replies

IDE :: IntelliSense Slow When List Filtering Large DataSet Hierarchy

Nov 21, 2007

I just converted my project from VS 2005 to 2008 and started getting really bad lag only when intellisense iterates my dataset objects. The cpu maxes out one of my cores for about 2-3 seconds each time the intellisense list pops up. Is this a new feature of the 2008 ide?

View 19 Replies

Save/export The Object File To .WAV File With Save Button?

Dec 22, 2011

i am coding a sound recorder with VB2010, how to save/export the object file to .WAV file with save button?

Public Class SoundRecorder
Dim soundrecord As Object
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA"

[Code].....

View 14 Replies

Save Whatever's In Clipboard To An Object?

May 3, 2009

I need to save the users clipboard contents to an object before I modify the clipboard, but I don't know how to do it.

View 3 Replies

.net - Save A Copy Of An Object And Restore It Later

May 12, 2012

I have a form which has a ListView and buttons to add/edit/delete items from this list. It has a save & a cancel button. On pressing the cancel button, I want to revert all the changes that have been done in the current form. So, while loading the form I keep a copy of the original list like below.

backupMyListView = MyListView

In the cancel button code, I do the opposite.

MyListView = refMyListView

Whats happening is that, the original listview is never restored because everytime MyListView was updated, backupMyListView also was getting updated.

How do I restore the original ListView on pressing the cancel button?

View 3 Replies

How To Save Bitmap Object As 8bit

May 16, 2010

I've created a new bitmap object and am shading some pixels inside it black using the setpixel function. At the end I do:
myBlankBitmap.Save("D:3Didea_out.bmp")
Great. Except the bitmap that is saved is 32bit and won't open properly. I want it to be 8 bit. I can't find any options to change the bitdepth.

View 10 Replies

Forms :: Save The Location Of The Object And Redraw?

Feb 12, 2011

I have developed an application where i am drawing line using the mouse like a pen (it can be of any shape) i want to save the location of the object and redraw it later using the drawn location saved on any xml or text file. Instead of saving the edited image i want to save the location only to save the space in the sql server.

View 2 Replies

Save & Load All Object Property Within A Form?

Oct 23, 2009

Save & Load all object property within a form??

I have been working on thread [URL], but it only limitation is it cannot save and load control that is child control (within groupbox, tabcontrol)..

View 2 Replies

.net Equivilent Of Ruby's Marshal - Object Save/load?

Jun 20, 2012

I'm just needing a simple bit of code for vb.net that will allow me to marshal an object into a string, allowing for the saving and loading of this string so I can save my classes, needs to be simple and easy!

View 1 Replies

How To Save Date Time Picker Object Value To Mysql

Aug 3, 2011

i want to save the value of date time picker control object to mysql but it kept saying error.the code perfectly works for text box values but it doesn't work for date time picker control.

View 1 Replies

Save Or Output WebBrowser Object Context To PDF File

Mar 10, 2010

I am loading an html page into a WebBrowser object in a VB.NET Windows Forms application. The user may make changes to textboxes, dropdowns, etc. on the HTML page displayed in the browser. I want the ability to save the current context to a .pdf file on the local HD. I am able to print using WebBrowser.Print(), which shows the current context, but what ways are possible to get this saved as a PDF file locally?

View 2 Replies

Link Or Multimedia Object - Change "save Target As..." Text

Jul 27, 2010

I have a vb form with a browser on it, when the mouse is over a link and I right-click on it, the pop-up appears containing "open, open in new tab, save target as..., copy shortcut, and so on" and for other types, appears "zoom in, show all, quality, play, loop, rewind, forward, back and so on". So is ther a way to figure out what kind is object is that, something like:

[Code]....

View 3 Replies

Application.Settings VB 2005 - Save Arrays Using The Settings System Object

Jan 14, 2009

I just wondered if you can or can't save arrays using the settings system object. There seems to be no way of entering it at designtime. It seems implied you cannot create new user settings.subobjects at runtime. I'm looking to find the easiest way to save a populated array of PictureBox's. If the only way is a self/custom made/managed .ini file then I need to know so i can start on that but I was hoping to use some of all this phaff in the new frameworks usefully.

View 3 Replies

"save" A Function Inside An Object?

Jul 2, 2010

I was wondering if it's possible to "save" a function inside an object. something like the following code

sub Proc1(a as integer)
Console.WriteLine(a)
end sub

[Code].....

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved