473,383 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Collections in a custom class

The code below is a class I am creating in order to help facilitate a
generic "data layer" assembly. Anyway, as you see the RecordCriteria class
contains three hashtables, and a structure called RecordCriteriaItem. I
want to be able to use a for each loop to loop through the values in the
hash tables (as you can see, each RecordCriteriaItem consists of the related
objects in the three Hashtables). Something like this:

Dim rc as RecordCriteria
....
Dim item as RecordCriteriaItem
For Each item in rc
...
Next

I have no idea how to accomplish this....
THE CODE!!!!-------------------------------------------------------------

Public Class RecordCriteria

Dim OpCodes As Hashtable
Dim Values As Hashtable
Dim IsNumber As Hashtable

Structure RecordCriteriaItem
Dim RemoteFieldName As String
Dim OpCode As String
Dim Value As Object
Dim IsNumber As Boolean
End Structure

Sub New()
If OpCodes Is Nothing Then OpCodes = New Hashtable
If Values Is Nothing Then Values = New Hashtable
If IsNumber Is Nothing Then IsNumber = New Hashtable
End Sub

Sub Add(ByVal RemoteFieldName As String, ByVal Opcode As String, ByVal
Value As Object, ByVal isnumeric As Boolean)
OpCodes.Add(RemoteFieldName, Opcode)
Values.Add(RemoteFieldName, Value)
IsNumber.Add(RemoteFieldName, IsNumber)
End Sub

Sub Remove(ByVal RemoteFieldName As String)
OpCodes.Remove(RemoteFieldName)
Values.Remove(RemoteFieldName)
IsNumber.Remove(RemoteFieldName)
End Sub

Function GetItem(ByVal remotefieldname As String) As RecordCriteriaItem
GetItem.IsNumber = IsNumber(remotefieldname)
GetItem.OpCode = OpCodes(remotefieldname)
GetItem.RemoteFieldName = remotefieldname
GetItem.Value = Values(remotefieldname)
Return GetItem
End Function

Function GetSQLWHERECriteria(ByVal remotefieldname As String) As String
Dim Text As String = "("
Text = Text & remotefieldname
Text = Text & " "
Text = Text & OpCodes(remotefieldname)
Text = Text & " "
If IsNumber(remotefieldname) <> True Then Text = Text & "'"
Text = Text & Values(remotefieldname)
If IsNumber(remotefieldname) <> True Then Text = Text & "'"
Text = Text & ")"
End Function

Function GetFullSQLWHEREClause() As String
Dim Text As String = " WHERE "
Dim i As IDictionaryEnumerator
For Each i In Values
Text = Text & "(" & i.Key & " = "
If IsNumber(i.Key) <> True Then Text = Text & "'"
Text = Text & i.Value
If IsNumber(i.Key) <> True Then Text = Text & "') AND "
Next
Text = Mid(Text, 1, Len(Text) - 4)
Return Text
End Function

End Class
Jul 21 '05 #1
2 1291
If you want to use the For Each statement with a custom
class, check out the below link. I think it might be
what you're looking for.

Paul K

http://msdn.microsoft.com/library/default.asp?
url=/library/en-
us/csref/html/vclrfusingforeachwithcollections.asp
Jul 21 '05 #2
Sorry, I gave you a C# link. Here's the VB link:

http://msdn.microsoft.com/library/default.asp?
url=/library/en-us/vbls7/html/vblrfvbspec8_10_3.asp

Paul K
-----Original Message-----
If you want to use the For Each statement with a custom
class, check out the below link. I think it might be
what you're looking for.

Paul K

http://msdn.microsoft.com/library/default.asp?
url=/library/en-
us/csref/html/vclrfusingforeachwithcollections.asp
.

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Anthony Bouch | last post by:
Hi I've been reading using the XmlSerializer with custom collections. I've discovered that when serializing a custom collection (a class that implements ICollection, IList etc.) the...
1
by: womber | last post by:
I am getting XML from a dataset that has been populated via a storedprocedure no schemas have been applied nor any relationships. But the correct table names have been given to match the table(s)...
0
by: Thomas D. | last post by:
Situation: --------------------------- I have an 'export'-wrapper to my regular objects. For each regular object there is also an export object. An export object derives from the regular object...
6
by: Chua Wen Ching | last post by:
Hi there, 1) I am looking for the best collections techniques to be used in my program. Is hashtable or arraylist or any .net collection, which is the fastest when adding, getting out data???...
3
by: Rob Thomas | last post by:
Hi, I've been tasked to come up with a new architecture for a large application at one of my customer's sites. In the past, I have developed multi-tier applications whereby the business...
7
by: rodchar | last post by:
hey all, i was checking out time tracker on asp.net one of the starter kit projects. i was wondering why the users datagrid gets loaded the way does. first it pulls all the users in from a...
0
by: Ross M | last post by:
Dear Microsoft, I m getting this error message, on every SECOND attempt to access a web service on a foreign PC. I am using .net framework 2 beta 2 with Visual Web developer 2. Below is the...
2
by: a | last post by:
The problem: I want to allow an administrator (user) to create a list of teachers, each teacher in turn has a list of classes, each class has a list of students. There's an article at...
3
by: Nick | last post by:
I am developing a new management system for my company, and with it have 3 layers of functionality written in VB.NET 2.0. In the business logic layer I have a user class which contains all user...
1
by: asharda | last post by:
I have a custom property grid. I am using custom property grid as I do not want the error messages that the propertygrid shows when abphabets are entered in interger fields. The custom property...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.