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
ADVERTISEMENT
Jan 11, 2009
Making a shape move more smoothly because at the moment the picture box moves around and can only go up down let or right and whenever i change direction there is a pause before it moves
Here is my code
CODE:
View 2 Replies
Dec 25, 2010
I'm making an application where a user draws a shape on a picture box( this will be saved on a bitmap image), then another user has to draw on that shape (=follow it ) . if the 2nd user goes too far from the line then an error message will appear.
for example( in case i couldn't clarify this well!)the 1st user draws a a vertical line, the 2nd user has to follow it, if-while drawing on it- he gets too far horizontally, there would be the error.
I'm currently thinking of comparing every point by the 2nd user to its equivalent in an array containing the points by the first user.
View 5 Replies
Mar 23, 2011
I am using Rack-mounted Equipment (US units).VSS as stencil. I need to Connect a server on Rack.
View 1 Replies
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
May 16, 2012
I'm a huge music person (got my own lil record thing going) but I'm wanting to design a program that would make music in my way. I have a decent amount of background knowlege of Visual Basic and Java I'm just wondering how could I execute this whole project. The Project is making a MPC Sampler. MPC is a drum machine; a machine with buttons that once you press it that it will play a sound from a drum (ex: snare, kick, tom, ect.) . So I would want to make some pads on my program that each have their own sound. Total of 16 pads. Which the design wouldn't be hard to make nor would the functionality of it having the play back sound (in my opinoin it wouldn't be hard atleast). But the thing is I wanna map out these pads to number keys on the number pad or keyboard. I'm not so sure how to do that. But that's all the easy stuff...
Also finding information is making a sound directory. What I mean by this is that I want to make a User Interface that will open up a file directory of sounds and the user can select what "kick" or "snare" sound he may want for the kick or snare pad. I don't know how to do that or even know what to search; neverless I don't know if this whole project idea is a good idea for Visual Basic or another programing language.
Also LATER ON I am wanting to add a record and export function that alows users to..well...record and export their beat or instrumental ha. That doesn't seem too too complex (mainly due to the fact that all it needs to do is record the users key strokes and then show them and play the sounds, but obviously it would get more complex than that.)
Here is an image of one of many MPCs but one with a directory - [URL]
View 5 Replies
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
Nov 23, 2011
1-When I click on the ''Square'' radio button I want the shape to appear in the image box, then need I only need 1 text box to appear where the 4 side boxes are, this will be where I enter the value of the sides to calculate the perimeter and I also want the area and perimeter boxes to appear at the bottom since I don''t need the volume text box.
[Code]...
View 10 Replies
May 27, 2010
I have a project(solution) which aims to lance a Form from a lancer module. On my Form Design the buttons are nice and round. When I go to Run the solution and the the Form is set as startup project, all is OK but when lancer module is set as startup project all buttons change to hard rectangular shapes and rounded corners dissapear (see attachments).
View 3 Replies
Dec 28, 2010
I want to be able to take a flat image and do this with it in my program
[code]...
how do I change the points?
how do I load only PART of an image from abitmap into bbitmap?
View 10 Replies
Mar 17, 2010
is there any way that you could change the shape of a button?
View 3 Replies
Sep 3, 2009
I need to change the shape of my tabs... untitled.JPG
View 2 Replies
Nov 17, 2011
how to change the shape of the end of the line
I would like to Cap type . Square, as here
View 9 Replies
Jul 14, 2010
Is there anyway to change the shape of the picture box into a round,cross or star shape
View 16 Replies
Jan 28, 2011
how do you correctly dispose a shape in vb.net ie when you draw a rectangle using the pen function how do I depose it so that it will disappear from the form, for some reason once its drawn if I draw a new shape it keeps the previous one and just overlays the new one and I use shape.dispose, and pen.dispose?
View 5 Replies
Jun 21, 2010
I want to create a window in a different shape. Not rectangular or eclipse but lets say a window look like a panda.!!!
View 1 Replies