Using VB.Net VS 2003 I am getting the following message when I call my 2nd
constructor.
Too many arguments to 'Public Sub New()'.
I have 2 constructors:
*************** *************** ****
Public Sub New()
End Sub
Public Sub New(initial As Object)
first = initial
data = initial
End Sub
*************** *************** ***
But these are in my Abstract class. If I inherit from my Abstract Class,
does each class have to have its own constructor or can I use the same
constructor as my Abstract class. That doesn't appear to be the case here.
I am trying to set up a class that handles data to/from a database that will
tell me whether the value is null or not, what the inital value was and
whether it has been changed.
So I set up an abstract class that does most of the work and then I will
have a small object for each type of variable (string, integer, boolean,
decimal etc).
So how the classes look at the start is:
*************** *************** *************
' Create to new variable types to handle nulls and track changes
' to standard variable types. This is for use with database variables.
' This will tell us if a vaiable has changed, give us the original and
current value,
' and tell us whether the current value and original value is/was null or
not.
imports System
imports System.IO
Namespace FtsData
MustInherit Class DataType
Private _first As Object
Private _data As Object
Private _changed As Boolean = False 'value changed from set
Private nullFirst As Boolean = False 'Was Null at start?
Private nullData As Boolean = False 'current data null
Public Sub New()
End Sub
Public Sub New(initial As Object)
first = initial
data = initial
End Sub
Public Function IsNull() As Boolean
return nullData
End Function
Public Function IsFirstNull() As Boolean
return nullFirst
End Function
Public Sub SetNull()
nullData = true
_data = ""
End Sub
Public Sub SetFirstNull()
nullFirst = true
_first = ""
End Sub
' Properties
Public Property First As Object
Get
return _first
End Get
Set
_first = value
End Set
End Property
Public Property Data As Object
Get
return _data
End Get
Set
_data = value
_changed = true
nullData = false
End Set
End Property
Public Property Changed as Boolean
Get
return _changed
End Get
Set
_changed = value
End Set
End Property
End Class
Class StringType : Inherits DataType
Private _first As String = "" 'original data
Private _data As String = "" 'current data
End Class
Class BooleanType : Inherits DataType
Private _first As Boolean = False 'original data
Private _data As String = False 'current data
End Class
End Namespace
*************** *************** *************
I am calling it from my program as:
*************** *************** *********
Imports DBTypesVB.FtsDa ta
Public Class Form1
Inherits System.Windows. Forms.Form
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim temp As New StringType
Dim temp2 As New StringType("The 2nd String")
temp.Data = "This is a test"
End Sub
End Class
*************** *************** *********
When I set "temp" it works fine.
When I set "temp2" - I get the error.
It doesn't see the 2nd Constructor.
Do I have to take the constructors out of the Abstract class and put them in
each of the other classes?
Thanks,
Tom 2 1431
Tom,
Constructors are not inherited. You need to create the constructors in any
inherited class.
Kerry Moorman
"tshad" wrote:
Using VB.Net VS 2003 I am getting the following message when I call my 2nd
constructor.
Too many arguments to 'Public Sub New()'.
I have 2 constructors:
*************** *************** ****
Public Sub New()
End Sub
Public Sub New(initial As Object)
first = initial
data = initial
End Sub
*************** *************** ***
But these are in my Abstract class. If I inherit from my Abstract Class,
does each class have to have its own constructor or can I use the same
constructor as my Abstract class. That doesn't appear to be the case here.
I am trying to set up a class that handles data to/from a database that will
tell me whether the value is null or not, what the inital value was and
whether it has been changed.
So I set up an abstract class that does most of the work and then I will
have a small object for each type of variable (string, integer, boolean,
decimal etc).
So how the classes look at the start is:
*************** *************** *************
' Create to new variable types to handle nulls and track changes
' to standard variable types. This is for use with database variables.
' This will tell us if a vaiable has changed, give us the original and
current value,
' and tell us whether the current value and original value is/was null or
not.
imports System
imports System.IO
Namespace FtsData
MustInherit Class DataType
Private _first As Object
Private _data As Object
Private _changed As Boolean = False 'value changed from set
Private nullFirst As Boolean = False 'Was Null at start?
Private nullData As Boolean = False 'current data null
Public Sub New()
End Sub
Public Sub New(initial As Object)
first = initial
data = initial
End Sub
Public Function IsNull() As Boolean
return nullData
End Function
Public Function IsFirstNull() As Boolean
return nullFirst
End Function
Public Sub SetNull()
nullData = true
_data = ""
End Sub
Public Sub SetFirstNull()
nullFirst = true
_first = ""
End Sub
' Properties
Public Property First As Object
Get
return _first
End Get
Set
_first = value
End Set
End Property
Public Property Data As Object
Get
return _data
End Get
Set
_data = value
_changed = true
nullData = false
End Set
End Property
Public Property Changed as Boolean
Get
return _changed
End Get
Set
_changed = value
End Set
End Property
End Class
Class StringType : Inherits DataType
Private _first As String = "" 'original data
Private _data As String = "" 'current data
End Class
Class BooleanType : Inherits DataType
Private _first As Boolean = False 'original data
Private _data As String = False 'current data
End Class
End Namespace
*************** *************** *************
I am calling it from my program as:
*************** *************** *********
Imports DBTypesVB.FtsDa ta
Public Class Form1
Inherits System.Windows. Forms.Form
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim temp As New StringType
Dim temp2 As New StringType("The 2nd String")
temp.Data = "This is a test"
End Sub
End Class
*************** *************** *********
When I set "temp" it works fine.
When I set "temp2" - I get the error.
It doesn't see the 2nd Constructor.
Do I have to take the constructors out of the Abstract class and put them in
each of the other classes?
Thanks,
Tom
"Kerry Moorman" <Ke**********@d iscussions.micr osoft.comwrote in message
news:BE******** *************** ***********@mic rosoft.com...
Tom,
Constructors are not inherited. You need to create the constructors in any
inherited class.
I thought so, but was hoping that wasn't the case.
Thanks,
Tom
>
Kerry Moorman
"tshad" wrote:
>Using VB.Net VS 2003 I am getting the following message when I call my 2nd constructor.
Too many arguments to 'Public Sub New()'.
I have 2 constructors: ************** *************** ***** Public Sub New() End Sub
Public Sub New(initial As Object) first = initial data = initial End Sub ************** *************** ****
But these are in my Abstract class. If I inherit from my Abstract Class, does each class have to have its own constructor or can I use the same constructor as my Abstract class. That doesn't appear to be the case here.
I am trying to set up a class that handles data to/from a database that will tell me whether the value is null or not, what the inital value was and whether it has been changed.
So I set up an abstract class that does most of the work and then I will have a small object for each type of variable (string, integer, boolean, decimal etc).
So how the classes look at the start is: ************** *************** ************** ' Create to new variable types to handle nulls and track changes ' to standard variable types. This is for use with database variables. ' This will tell us if a vaiable has changed, give us the original and current value, ' and tell us whether the current value and original value is/was null or not.
imports System imports System.IO
Namespace FtsData MustInherit Class DataType Private _first As Object Private _data As Object Private _changed As Boolean = False 'value changed from set Private nullFirst As Boolean = False 'Was Null at start? Private nullData As Boolean = False 'current data null
Public Sub New() End Sub
Public Sub New(initial As Object) first = initial data = initial End Sub
Public Function IsNull() As Boolean return nullData End Function
Public Function IsFirstNull() As Boolean return nullFirst End Function
Public Sub SetNull() nullData = true _data = "" End Sub
Public Sub SetFirstNull() nullFirst = true _first = "" End Sub
' Properties
Public Property First As Object Get return _first End Get Set _first = value End Set End Property
Public Property Data As Object Get return _data End Get Set _data = value _changed = true nullData = false End Set End Property
Public Property Changed as Boolean Get return _changed End Get Set _changed = value End Set End Property End Class
Class StringType : Inherits DataType Private _first As String = "" 'original data Private _data As String = "" 'current data End Class
Class BooleanType : Inherits DataType Private _first As Boolean = False 'original data Private _data As String = False 'current data End Class
End Namespace ************** *************** **************
I am calling it from my program as: ************** *************** ********** Imports DBTypesVB.FtsDa ta
Public Class Form1 Inherits System.Windows. Forms.Form
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventAr gs) Handles MyBase.Load Dim temp As New StringType Dim temp2 As New StringType("The 2nd String")
temp.Data = "This is a test" End Sub End Class ************** *************** **********
When I set "temp" it works fine. When I set "temp2" - I get the error.
It doesn't see the 2nd Constructor.
Do I have to take the constructors out of the Abstract class and put them in each of the other classes?
Thanks,
Tom This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Amadrias |
last post by:
Hi all,
I am using a class to transport some data over the
network. I then added the attribute to the
class.
My problem is that this class is part of a framework and
that I do not want developers to call empty constructors.
But the runtime sends me an exception when I try to
serialize this class asking me to provide it with an
|
by: John Brock |
last post by:
I have a base class with several derived classes (I'm writing in
VB.NET). I want each derived class to have a unique class ID (a
String), and I want the derived classes to inherit from the base
class *Shared* methods which make use of the class ID.
So I gave the base class a classID field, and then I gave the
derived classes Shared constructors, which I used to set the classID
field to the appropriate values for each derived class. But...
|
by: Ben Blank |
last post by:
I'm writing a family of classes which all inherit most of their methods and
code (including constructors) from a single base class. When attempting to
instance one of the derived classes using parameters, I get CS1501 (no method
with X arguments). Here's a simplified example which mimics the
circumstances:
namespace InheritError {
// Random base class.
public class A {
protected int i;
|
by: Carl Fenley |
last post by:
I've been programming exclusively in C# for the last few years but am now
working on a project where I am required to write all code in VB.NET.
I'm trying to create a class with multiple overrideable contructor methods.
The problem is that I don't know how to even define a contructor in VB.NET,
let alone inherit the default contructor. Here is what I have so far:
Public Class AppSnippets
Private _instances As Integer
Private...
|
by: Dave A |
last post by:
I have a class that does not have a default constructor. The nature of the class inherently excludes it from having one and to put one in will blatantly misrepresent the object that it is modelling.
So having said that, how do I get it to go through SOAP when SOAP requires that the class has a default constructor?
In ASP.NET 2 the error message is "<class> cannot be serialized because it does not have a parametless constructor" (please...
| |
by: Andrew Backer |
last post by:
Hello,
I am having a problem creating a class dynamically. The class I have
is a base class of another, and the parent class has the constructor
(which takes one argument). The base class (Class1, below) does not
have any constructors. I am using code like this to create it, and
it's blowing up :
Dim res As Object = Activator.CreateInstance( _
GetType( MyNameSpace.Class1 ), _
|
by: =?Utf-8?B?cnZtYWNjb3VudA==?= |
last post by:
It seems the static constructor is supposed to be called, ONLY once for a
particular type. If that's the case, why does the following code throws an
exception?
using System;
using System.Collections.Generic;
using System.IO;
namespace GenericTypes
{
|
by: clicwar |
last post by:
A simple program with operator overloading and copy constructor:
#include <iostream>
#include <string>
using namespace std;
class Vector {
private:
float x,y;
public:
Vector(float u, float v);
|
by: Rahul |
last post by:
Hi Everyone,
While working with Java, i came across super() which passes values to
base class constructor from derived class constructor. I was wondering
if this could be implemented in c++ by any mechanism as super is not
supported by c++, atleast by MS vc++ 6.0.
|
by: l.s.rockfan |
last post by:
Hello,
how do i have to call an inherited, templated class constructor from the
initializer list of the inheriting, non-templated class constructor?
example code:
template<typename T>
class A
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |