It was SO easy in VB6. Add a few methods, set a few funky properties and
*BAM*, type-safe collection class that supports the For Each...Next syntax.
I've been trying to do this in VB.NET with little success.
I started inherting DictionaryBase because of the Key retrieval ability, but
my code bombed on the For Each line because I had Option Strict On and the
types didn't match. I now loop with an Object and then use CType, but that's
BS! >8-(
Do I need to create my own Enumerator and overload Current()?
C'mon Generics!!!
Thanks in advance for help,
Andrew J. Marshall
MCP (Visual Basic)
Fairfax, VA 3 2881
Try this..
(It is a collection of ContractSale objects). It will support the For...Each that you requir
Public Class ContractSale
Inherits CollectionBas
Public Function Add(ByVal strBranchNo As String, ByVal intTillNo As Integer,
ByVal strReceiptNo As String, ByVal strCompositeRec eiptNo As String,
ByVal intContractID As Integer, ByVal strBarcode As String,
ByVal dteSaleDate As Date, ByVal strSurname As String,
ByVal strMobileNo As String, ByVal strIMEI As String,
ByVal strSIM As String,
ByVal strNetwork As String, ByVal strImageFileNam e As String) As ContractSal
Dim objNew As New ContractSal
With objNe
.BranchNo = strBranchN
.TillNo = intTillN
.ReceiptNo = strReceiptN
.CompositeRecei ptNo = strCompositeRec eiptN
.ContractID = intContractI
.Barcode = strBarcod
.SaleDate = dteSaleDat
.Surname = strSurnam
.MobileNo = strMobileN
.IMEI = strIME
.SIM = strSI
.Network = strNetwor
.ImageFileName = strImageFileNam
End Wit
list.Add(objNew
Add = objNe
End Functio
Public Sub Remove(ByVal intIndex As Integer
list.RemoveAt(i ntIndex
End Su
Public ReadOnly Property Item(ByVal intIndex As Integer) As ContractSal
Ge
Return CType(list.Item (intIndex), ContractSale
End Ge
End Propert
End Clas
----- Andrew J. Marshall wrote: ----
It was SO easy in VB6. Add a few methods, set a few funky properties an
*BAM*, type-safe collection class that supports the For Each...Next syntax
I've been trying to do this in VB.NET with little success
I started inherting DictionaryBase because of the Key retrieval ability, bu
my code bombed on the For Each line because I had Option Strict On and th
types didn't match. I now loop with an Object and then use CType, but that'
BS! >8-
Do I need to create my own Enumerator and overload Current()
C'mon Generics!!
Thanks in advance for help
Andrew J. Marshal
MCP (Visual Basic
Fairfax, V
The DictionaryBase enumerator returns DictionaryEntry objects rather than
the objects you store in the collection. This allows you to have a
reference both to the object and its associated with key. So, to use
For-Each with a DictionaryBase-derived class you need to do something
similar to the following: -
For each de as DictionryEntry in MyCollection
Dim item as MyClass = DirectCast(de.C urrent, MyClass)
'....Use as necessary
Next de
Nick Hall
"Andrew J. Marshall" <An************ *@ObjectVision. netANTISPAMDEVI CE> wrote
in message news:%2******** ********@TK2MSF TNGP11.phx.gbl. .. It was SO easy in VB6. Add a few methods, set a few funky properties and *BAM*, type-safe collection class that supports the For Each...Next
syntax. I've been trying to do this in VB.NET with little success.
I started inherting DictionaryBase because of the Key retrieval ability,
but my code bombed on the For Each line because I had Option Strict On and the types didn't match. I now loop with an Object and then use CType, but
that's BS! >8-(
Do I need to create my own Enumerator and overload Current()?
C'mon Generics!!!
Thanks in advance for help, Andrew J. Marshall MCP (Visual Basic) Fairfax, VA
Howler,
Thanks!
I actually started with CollectionBase, but I needed access to items by a
key so I switched to DictionaryBase. Any thoughts?
Andrew J. Marshall
MCP (Visual Basic)
Fairfax, VA
"The Howler" <an*******@disc ussions.microso ft.com> wrote in message
news:E0******** *************** ***********@mic rosoft.com... Try this...
(It is a collection of ContractSale objects). It will support the
For...Each that you require Public Class ContractSales Inherits CollectionBase
Public Function Add(ByVal strBranchNo As String, ByVal intTillNo As
Integer, _ ByVal strReceiptNo As String, ByVal
strCompositeRec eiptNo As String, _ ByVal intContractID As Integer, ByVal strBarcode
As String, _ ByVal dteSaleDate As Date, ByVal strSurname As
String, _ ByVal strMobileNo As String, ByVal strIMEI As
String, _ ByVal strSIM As String, _ ByVal strNetwork As String, ByVal strImageFileNam e
As String) As ContractSale Dim objNew As New ContractSale
With objNew .BranchNo = strBranchNo .TillNo = intTillNo .ReceiptNo = strReceiptNo .CompositeRecei ptNo = strCompositeRec eiptNo .ContractID = intContractID .Barcode = strBarcode .SaleDate = dteSaleDate .Surname = strSurname .MobileNo = strMobileNo .IMEI = strIMEI .SIM = strSIM .Network = strNetwork .ImageFileName = strImageFileNam e End With
list.Add(objNew ) Add = objNew
End Function Public Sub Remove(ByVal intIndex As Integer) list.RemoveAt(i ntIndex) End Sub
Public ReadOnly Property Item(ByVal intIndex As Integer) As
ContractSale Get Return CType(list.Item (intIndex), ContractSale) End Get End Property
End Class ----- Andrew J. Marshall wrote: -----
It was SO easy in VB6. Add a few methods, set a few funky properties
and *BAM*, type-safe collection class that supports the For Each...Next
syntax. I've been trying to do this in VB.NET with little success.
I started inherting DictionaryBase because of the Key retrieval
ability, but my code bombed on the For Each line because I had Option Strict On
and the types didn't match. I now loop with an Object and then use CType, but
that's BS! >8-(
Do I need to create my own Enumerator and overload Current()?
C'mon Generics!!!
Thanks in advance for help, Andrew J. Marshall MCP (Visual Basic) Fairfax, VA This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: John Haney |
last post by:
Postgresql 7.4.3-1 under Cygwin.
I created a table called ServerTypes:
CREATE TABLE ServerTypes(
ServerTypeID SERIAL UNIQUE NOT NULL,
Type TEXT PRIMARY KEY);
Works fine.
|
by: anon |
last post by:
I have been used to using DAO in the past, and then converted to ADO.
Now I am having to use VB.Net(2000) and ADO.NET and am experiencing
difficulties with the creation and population of an mdb.
I can create the MDB and am doing so by creating a module as shown below.
I have added the ADO reference: Microsoft ADO Ext. 2.7 for DDL and
Security in the references section of the project.
This creates the MDB but as soon as it tries to...
|
by: Alex Page |
last post by:
This is probably really basic, but I can't seem to get it to work. I'm
trying to create an enumerated type, using the following code:
CREATE FUNCTION enum_gender_in (cstring) RETURNS enum_gender IMMUTABLE AS
'DECLARE invalue ALIAS FOR $1;
BEGIN
IF invalue=''Male'' OR invalue=''0'' THEN RETURN 0; END IF;
IF invalue=''Female'' OR invalue=''1'' THEN RETURN 1; END IF;
RAISE EXCEPTION ''Incorrect input value: %'', invalue;
END;'
|
by: jab |
last post by:
Je veux lier (join) une table qui se trouve dans une database avec une
qui se trouve dans une autre database. Les 2 databases sont sur le
même serveur en l'occurence DB2/NT 7.2.9. J'ai créé un wrapper avec le
control center (j'ai utilisé DRDA) et ensuite j'ai voulu créé le
serveur mais avec le wizard, il ne me présente pas mes tables !
J'ai donc essayé en ligne de commande. J'ai essayé la commande
suivante:
CREATE SERVER TEST TYPE...
|
by: Vinay Jain |
last post by:
Hi
I am newbie so this problem may be too simple to be asked.please help me if
any new thing to be added in following:
I want to use user defined data type in User_Type(n) way....
I created data type IndChar The c functions are:
/* Definaton of Data Type) */
typedef struct IndChar
| |
by: DotDidIt |
last post by:
Hi Everybody!
I developed a Web service with IBM RAD v 6.0.1.
After creating the WSDL file i have tried to develop a .Net client.
But by using wsdl.exe (1.1.4322) to create a .net c# proxy i get the
following error message:
Schema parsing error Namespace 'http://session.ejbs.cac.commerce.com'
is not available to be referenced in this schema.
Schema parsing error Namespace 'http://session.ejbs.cac.commerce.com'
|
by: mesut demir |
last post by:
Hi All,
When I create fields (in files) I need assign a data type like char,
varchar, money etc.
I have some questions about the data types when you create fields in a
file.
What is the difference between data type 'CHAR' and 'TEXT'?
When do you use 'VAR' in your datatype word? e.g. VARCHAR ?
|
by: windandwaves |
last post by:
Hi Folk
Some of my clients asked me to create "fancy emails" for them (aka html
formatted emails).
I know how to make a nice html document, but I had trouble creating a simple
way to provide the document to my clients so that they could use it to.
I know most of them use Outlook XP or Outlook 2003, so what I created was a
page that creates a Visual Basic script that, when saved to the desktop and
|
by: markmcgookin |
last post by:
Hi Folks,
Bear with me if this sounds stupid pls!
I have an xsl doc that is translating one type of xml to another (still with me?)
I was wondering, is it possible to do the same thing to create a schema?
I really need to be able to fly through the doc, and go:
|
by: ebusiness |
last post by:
I am trying to create nicknames for tables in a remote database. The
federated database and remote database are both DB2 UDB V8.2, both OS
are AIX.
Could anyone tell me how to create a nickname for a remote table with
distinct data type? I try to create a type maaping for the remote
distinct data type, but the system always returns the error SQL0604N.
Is type mapping or nickname on distinct type supported in db2 udb
v8.2?
|
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: 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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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: 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: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| | |