Dear All,
I have written a common array class which has insert, search and other
functions.
For Example (Code in VB.NET):
' Client Class
Public Class Client
Public ClientCode As String 'Key Field
Public ClientName As String
...
End Class
'Client Array Class - Similar to a Vector Class
Public Class ClientArray
Private _ArrayIn() As Client
'Inserts the value into the _ArrayIn()
Public Function Insert(ByVal value As Client) As Long
....
End Function
'Searches the array
Public Function Search(ByVal value As Client) As Long
' GetSearchKey - Use this function to get the value in the "_ArrayIn() "
and "value" and compare
....
End Function
' Gets the search key.
Private Function GetSearchKey(By Val value As Client) As String
Return value.ClientCod e
End Function
End Class
Similary I have many classes like the Client Class, Say
' Scrip Class
Public Class Scrip
Public ScripCode As Integer 'Key Field
Public ScripName As String
Public Exchange As Short
Public Symbol As String
Public Market As String
...
End Class
Instead of creating a ScripArray Class with the same functionality as the
ClientArray Class, Can I make a Common Array Class and create a instance of
the Common Array Class with Type as Client or Scrip?
Please help me out
--
Thanks and Regards,
Peri 9 1412
List<Clientand List<Scrip>
or
Collection<Clie ntand Collection<Scri pt>
job done
(don't ask me what the VB.NET syntax is; you cross-posted to a C#
ng...)
Marc
Dear Marc,
If I use a list of a collection then I cannot write my own insert, search,
resize funtionalities. I would like to create my own insert/search and also
need to implement similar to a list or a collection.
"Marc Gravell" <ma**********@g mail.comwrote in message
news:%2******** **********@TK2M SFTNGP05.phx.gb l...
List<Clientand List<Scrip>
or
Collection<Clie ntand Collection<Scri pt>
job done
(don't ask me what the VB.NET syntax is; you cross-posted to a C# ng...)
Marc
Dear Marc,
If I use a list of a collection then I cannot write my own insert, search,
resize funtionalities. I would like to create my own insert/search and also
need to implement similar to a list or a collection.
"Marc Gravell" <ma**********@g mail.comwrote in message
news:%2******** **********@TK2M SFTNGP05.phx.gb l...
List<Clientand List<Scrip>
or
Collection<Clie ntand Collection<Scri pt>
job done
(don't ask me what the VB.NET syntax is; you cross-posted to a C# ng...)
Marc
Peri wrote:
If I use a list of a collection then I cannot write my own insert, search,
resize funtionalities. I would like to create my own insert/search and also
need to implement similar to a list or a collection.
Why not?
What about List<T>/Collection<Tdoe sn't do what you're looking for?
Chris.
Dear Chris,
In My code, if you see in the common array which I have written I have
declared a variable called "Private _ArrayIn() As Client" and methods like
"Public Function Search(ByVal value As Client) As Long" which has "Client"
has a type. Instead of "Client", If I need to have it as "Scrip" then how do
I do this?
I hope what you are telling me is: In another class where we are
implementing this client/scrip array, you are asking me to put
"Dim clientArrayList As New List(Of Client)"
The Code:
----------
'Client Array Class - Similar to a Vector Class
Public Class ClientArray
Private _ArrayIn() As CLIENT
'Inserts the value into the _ArrayIn()
Public Function Insert(ByVal value As Client) As Long
....
End Function
'Searches the array
Public Function Search(ByVal value As CLIENT) As Long
' GetSearchKey - Use this function to get the value in the "_ArrayIn() "
and "value" and compare
....
End Function
' Gets the search key.
Private Function GetSearchKey(By Val value As CLIENT) As STRING
Return value.CLIENTCOD E
End Function
End Class
Thanks and Regards,
Peri
"Chris Shepherd" <ch**@nospam.ch sh.cawrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
Peri wrote:
>If I use a list of a collection then I cannot write my own insert, search, resize funtionalities. I would like to create my own insert/search and also need to implement similar to a list or a collection.
Why not?
What about List<T>/Collection<Tdoe sn't do what you're looking for?
Chris.
Public Function Search(ByVal value As Client) As Long
What does that return? The index of the item? In which case
..IndexOf(T) is already implemented in both List<Tand Collection<T>.
In the more general sense with generics, you simply have (using C#
syntax, but same is possible in VB.NET):
public class SomeClass<T{
public int SomeMethod(T someArgument) {...}
}
Marc
On Oct 16, 1:58 pm, "Peri" <P...@discussio ns.microsoft.co mwrote:
In My code, if you see in the common array which I have written I have
declared a variable called "Private _ArrayIn() As Client" and methods like
"Public Function Search(ByVal value As Client) As Long" which has "Client"
has a type. Instead of "Client", If I need to have it as "Scrip" then how do
I do this?
You need to use generics. However, if you're writing VB.NET code you'd
be a lot better asking in a VB group than a C# one.
Jon
On Oct 16, 7:58 am, "Peri" <P...@discussio ns.microsoft.co mwrote:
>
I hope what you are telling me is: In another class where we are
implementing this client/scrip array, you are asking me to put
"Dim clientArrayList As New List(Of Client)"
If a List(Of Client) does not suit your needs, you can try to make
your own class generic. Something like this:
'Client Array Class - Similar to a Vector Class
Public Class Array(Of T)
Private _ArrayIn() As T
'Inserts the value into the _ArrayIn()
Public Function Insert(ByVal value As T) As Long
....
End Function
'Searches the array
Public Function Search(ByVal value As T) As Long
' GetSearchKey - Use this function to get the value in the
"_ArrayIn() "
and "value" and compare
....
End Function
' Gets the search key.
Private Function GetSearchKey(By Val value As T) As String
Return value.ClientCod e
End Function
End Class
Then you can declare and instance of this class like this:
Dim MyClientArray as New Array(Of Client)
or
Dim MyScripArray As new Array(Of Scrip)
or whatever.
You see if this can suit your needs.
Chris
Thanks Chris,
But the GetSearchKey is not working since it returns Return value.ClientCod e
(This is only for Client), If scrip then it should be Return
value.ScripCode .
Is there a way to implement this?
Thanks and Regards,
Peri
"Chris Dunaway" <du******@gmail .comwrote in message
news:11******** **************@ z24g2000prh.goo glegroups.com.. .
On Oct 16, 7:58 am, "Peri" <P...@discussio ns.microsoft.co mwrote:
>> I hope what you are telling me is: In another class where we are implementing this client/scrip array, you are asking me to put "Dim clientArrayList As New List(Of Client)"
If a List(Of Client) does not suit your needs, you can try to make
your own class generic. Something like this:
'Client Array Class - Similar to a Vector Class
Public Class Array(Of T)
Private _ArrayIn() As T
'Inserts the value into the _ArrayIn()
Public Function Insert(ByVal value As T) As Long
....
End Function
'Searches the array
Public Function Search(ByVal value As T) As Long
' GetSearchKey - Use this function to get the value in the
"_ArrayIn() "
and "value" and compare
....
End Function
' Gets the search key.
Private Function GetSearchKey(By Val value As T) As String
Return value.ClientCod e
End Function
End Class
Then you can declare and instance of this class like this:
Dim MyClientArray as New Array(Of Client)
or
Dim MyScripArray As new Array(Of Scrip)
or whatever.
You see if this can suit your needs.
Chris This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Phil... |
last post by:
I am trying to figure out how to create an array that contains objects
and not references to objects. I know how to do the latter, but not
the former. Any help is appreciated.
I have the following:
class ArrayTest extends Frame {
public static void main(String args) {
<snip>
Jones arr; // arr is an array of class Jones objects
arr = new Jones; // allocate the array
|
by: Steven T. Hatton |
last post by:
This is something I've been looking at because it is central to a currently
broken part of the KDevelop new application wizard. I'm not complaining
about it being broken, It's a CVS images. Such things happen. The whole
subsystem is going through radical changes. I don't really want to say
what I think of the code just yet. That would influence the opinions of
others, and I really want to know how other people view these things,...
|
by: Taiwo |
last post by:
I generated a Typed Dataset class including a base64Binary column. This
column was specified as a .NET type of Byte() in the class that was
auto-generated. I set the value of this property to New Byte() {} (i.e. Byte
array with zero elements) in a row of an instance of the class prior to
serialization using the binary formatter. When I attempt to DeSerialize the
instance, the following exception is thrown:
:...
|
by: scottyman |
last post by:
I can't make this script work properly. I've gone as far as I can with
it and the rest is out of my ability. I can do some html editing but
I'm lost in the Java world. The script at the bottom of the html page
controls the form fields that are required. It doesn't function like
it's supposed to and I can leave all the fields blank and it still
submits the form. Also I can't get it to transfer the file in the
upload section. The file name...
|
by: john |
last post by:
I am VERY new to C++ (1st semester) put not so new to coding and
programming (SQL, VB, etc). We are learning about classes.
I have a program that needs to call many instances (i think this is the
right term) of a class.
What I have been taught so far is to write to a class we would do
something like this in the main.cpp:
a1.setmanSalary(something);
| |
by: zzw8206262001 |
last post by:
Hi,I find a way to make javescript more like c++ or pyhon
There is the sample code:
function Father(self) //every contructor may have "self"
argument
{
self=self?self:this; //every class may have this statement
self.hello = function()
{
|
by: jeff.sharkfinn |
last post by:
I'm trying to create a pointer to a class in form1.h button1 event
handler. It should be simple... but no. This example is as simple as I
can make:
Form1.h (produced with the designer containing a single button)
***********************************************************************************
#pragma once
namespace MyProject {
|
by: Peri |
last post by:
Dear All,
I have written a common array class which has insert, search and other
functions.
For Example (Code in VB.NET):
' Client Class
Public Class Client
Public ClientCode As String 'Key Field
|
by: raylopez99 |
last post by:
I suspect the answer to this question is that it's impossible, but how
do I make the below code work, at the point where it breaks (marked
below). See error CS0411
This is the complete code. Copy and paste it into VS2008 for a
Windows Forms application.
With some effort I can do the job with a user defined function, but my
question is whether I can do it using the built in library function
"Array.Find" and a predicate that takes...
|
by: nuffnough |
last post by:
I have defined two classes with one common field (called code) and
several different fields.
In class A there is only one instance of any given code as all items
are individual.
In class B, there may be none, one or many instances of each code, as
there can be any number of Bs referring to a single A.
I need to make a list of Bs, remove dupes, and then create a list of
As that have Bs.
|
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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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...
| |