Difference Between Inheriting And Creating Object Of A Class?
Jun 29, 2010When we can access the public methods via object then why is there need of inheritance.
View 2 RepliesWhen we can access the public methods via object then why is there need of inheritance.
View 2 RepliesWhat is neater / better in your opinion? Inheriting a Class with useful methods or a creating a module?
For example:
vb Module Tools_Module
Public Sub Print(ByRef text As String)
Console.WriteLine(text)
End Sub
End Module
[Code]...
I'm using vb10. I need to use a timer for forms to turn off and on and I was going to use a timer control and I noticed there is a timer class. What is the difference? Should I use the timer class instead?
View 5 RepliesI`m a beginning programmer, and I`m trying to build my first 100% object. The object would be a USER object, representing rekords from users table in database. The table in the database has 5 columns ->
[Code]...
my aim is to create a new instance box at the push of a button, the box has strings name and Id to be filled concatenating the auto generated ID i.e. 0 to 210 plus a string "Box" added by the user. I had problems earlier creating a structure within the class box, frankly I am not sure if the code below will work, as i try to run it in VB I get an error indicating that I am using the variables strBoxPositions() and strBoxNumbers() without assigning a value to it. The thing is the strBoxPositions() should automatically be filled by arrPosition() which will be created at the same time the new object box is created and the strNumbers() will be created with empty strings to be filled at latter stage by the used as and when necessary.
how could I initialise those arrays to get the program to run and perhaps ill be able to see if the code works or not, or just correct this code with a better way of code with comments, also if possible some indication on how could I update the strNumbers array inputing the strings one at a time on a text box field.
Public class form1
Public Class Box
Public intBoxID As Integer
[Code].....
In the below mockup, how do I find out, if I am an instance of FooDAL or WeeDAL from within the method DoMagix()?
Public MustInherit Class DataAccessClass
Public Sub DoMagix()
'** LOOK AT ME!!! **
[code].....
How would I create my custom Role class based on that autogenerated class? I have read a few articles on the net but I am still lost. Can someone please show me how to do this, and what I must import(using visual basic). I want to add some validation to the string property where Role1 cannot be more than 50 characters.
Autogenerated class
[Code]...
I want to implement a priority queue class. When an item is added at a higher priority it is pushed to the front of the queue instead adding to the end of queue. Simple few lines of code
[Code]...
I've created a class called connector. By clicking on project and adding a class.And I want to inherit from that class in the forms But I get this error.
Base class '<baseclassname1>' specified for class '<partialclassname>' cannot be different from the base class '<baseclassname2>' of one of its other partial types`
what do I do?Here's the class named connect.vb:Imports MySql.Data.MySqlClient
[Code]...
I have 2 business classes, user & salutation and 2 DAL classes of the same name.
The business classes both have properties of the data class E.g.
Public Property Data() As Data.Salutation
Get
Return _Data
[Code].....
To access some data, you would do Business.Salutation.Data.SalutationID
Both busines classes inherit from BaseClass which contains all my database access methods.
Is there a way that I can access the Data property of the inheriting classes from the BaseClass?
I assume I will need to use reflection as the property types will always be different.
Most of our code base is in VB.NET. I'm developing a project in C# that uses a lot of the assemblies from the VB.NET code.There are three relevant classes in VB.NET:
[Code]...
I want to define a generic interface which will be implemented by an abstract Generic Class. Basically this generic class is a collection class of any class. Interfaces are in a separate project saved as FileReconciliation. Here are the interface definitions
Interfaces
Imports System.Collections
Public Interface ICollectionCommon(Of T As Class)
Inherits IEnumerable
Function Exists(ByVal oKey As Object) As Boolean
[Code] .....
I seem to be having a problem with controls that I am creating as new classes (not UserControls) inheriting from an existing system control. Everything seems ok while I create the control code, through to the compile (which is successful and adds the control to the toolbox) and dragging the control from the toolbox to the GUI surface. However, when I then debug or compile the project, I get a message such
[Code]...
When inheriting class or control e.g. ListView, TreeView, etc..., what is the best way to distinguish between built-in methods/property/events and mine?
Currently, i start my methods/property/events with "aa" in order to make them at the top of auto complete list.
I have a Class FileDoc Public Class FileDoc Inherits BaseClass
Public Sub DeleteDoc() dim catId as integer = Cat_ID
[Code]...
My question is, since FileDoc comes from the BaseClass, how can I access values from the BaseClass when I'm coding in the FileDoc Class. Like my example in sub DeleteDoc(), I'm trying to access the Cat_ID of the Base Class which this FileDoc belongs to.Adding an inheritance doesn't transfer the values to the class, only the properties.
I wonder, is there any difference between these two line of code in perfomance (suppose we have class called Car)?
Dim c = New Car
Dim c As New Car
I can't make difference between public class and private class and friend and protected friend class.
View 1 RepliesI am utilizing a centralized class object that needs to call another class object. The program itself will do something like the following
sFieldValue = CentralObject.ObjectHandler(1, TestFunction, "FunctionVar,FunctionVar2,FunctionVar3")
In the central object I have a function
Public
Function ObjectHandler(ByVal ObjectType
As
Integer,
[code]....
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?
I am converting C# to VB right now
in VB, I have these codes :
Dim ind As Foo.Index
Dim ed As Foo.Edit
ind = New Foo.Index
[Code]....
Seems I do need to show all the codes. But I need to talk directly to you as well (or You just install the software of mine).
If I create a class in VB called Test,I noticed I can instantiate it like:
Dim test As New Test
or
Dim test As New Test()
What is the difference?
I want to know the difference. I have given 2 lines code.
CODE:
Let me know difference between both datatype.
I'm trying to create a pivot table by opening an Excel file from my drive.But I'm receiving the error saying "Object reference not set to an instance of an object".[code]
View 1 RepliesI'm having this problem with my code and cannot seem to get past it although it was working fine before. The error is "An error occurred creating the form. See Exception.InnerException for details. The error is: Object reference not set to an instance of an object." The code is:
CODE:
I am trying to get information to be pulled out of a database and show in text boxes on another form (frmviewsdets). The error occurs when it gets to the line frmviewsdets.txtsnumber.Text = rdr("StudentNumber") and even when a breakpoint is applied there it just moves on to the next and so on.
I have tried to show frmviewsdets before I pull the data out of the database beut I get the same message.
Dim MyOrders As Order()
Dim MyOrders2() As Order
if I created a new object like this Dim sqlconn As New SqlClient.SqlConnection(cs)
and Dim sqlconn = New SqlClient.SqlConnection(cs) Whats the difference?
explain to me the differences between an abstract class and a class marked MustInherit?
Both can implement shared and instance constructors and logic. Both can/must be inherited.
So why use one over the other and what is the difference?
Edit: Sincerely apologize I have got my languages mixed up. Will mark correct answer as soon as I am allowed.
What is the difference between Private Sub /private Function / Private Class and to use them?
View 4 RepliesI asked a question earlier where I was told a simple way to "bind data to objects" is to just run a SqlConnection(connectionString). The response also included a comment saying I could get fancy with L2S and Entity Frameworks, so I looked deeper into those. It seems all you have to do with the DataContext object is point to the database. Why would SqlConnection be a benefit? What is the difference (or pros/cons) of using either one of these? Is one more "standard"? Is one more modern?
View 1 RepliesI've been working in .NET for some time now, but occasionally I still get confused by a disparity between the framework and my prior experience in C++.In .NET, all objects are either value types or reference types. Reference types are allocated on the heap while value types are allocated on the stack (in the current CLR implementation, anyway). I get that. However, at least in VB.NET, you can still define a constructor on a value type.
Public Structure Coordinates
Public x As Integer
Public y As Integer
[code]....