473,320 Members | 2,000 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,320 software developers and data experts.

Best Method

I am looking for a way to store maybe in an array or dictionary... two
fields....
first field would be a string... second would be a date...
for example.. if i called up myinfo(0) it would show "the first Day"
"1/1/2008" ???
Brian
Jun 27 '08 #1
7 881
Brian,

What do you want to do store data or put data in a class.

For two values the latter is in my idea without sense, and for that are 100
best methods.

The same is for store this kind of data, there are probably 20 best methods.

One of those maybe this one.

http://msdn.microsoft.com/en-us/library/3ak841sy.aspx

Cor
"Brian" <bs********@community.nospamschreef in bericht
news:un**************@TK2MSFTNGP05.phx.gbl...
>I am looking for a way to store maybe in an array or dictionary... two
fields....
first field would be a string... second would be a date...
for example.. if i called up myinfo(0) it would show "the first Day"
"1/1/2008" ???
Brian

Jun 27 '08 #2
On May 14, 9:26 pm, "Brian" <bsgalla...@community.nospamwrote:
I am looking for a way to store maybe in an array or dictionary... two
fields....
first field would be a string... second would be a date...
for example.. if i called up myinfo(0) it would show "the first Day"
"1/1/2008" ???
Brian
Sounds to me you just need to make a custom class that has two
properties, label and date:

//////////////
Public Class YourClassNameHere

Private _Label As String = String.Empty
Private _TheDate As DateTime = DateTime.Now

Public Sub New()

End Sub

Public Sub New(ByVal label As String, ByVal theDate As DateTime)
Me.New()

Me.Label = label
Me.TheDate = TheDate
End Sub

Public Property Label As String
Get
Return _Label
End Get
Set (ByVal value As String)
_Label = value
End Set
End Property

Public Property TheDate As DateTime
Get
Return _TheDate
End Get
Set (ByVal value As DateTime)
_TheDate = value
End Set
End Property

'// I typed this in the message so this statement might
'// not be formatted correctly
Public Overrides Function ToString() As String
Return String.Format("{0} {1}", Me.Label, Me.TheDate)
End Function

End Class
//////////////

Then you could just store these objects in any sort of IEnumerable
field (array, list, arraylist, etc) and then when you pull them out of
the array (or whatever) and call the .ToString() method, you will get
the string like you requested.

Thanks,

Seth Rowe [MVP]
Jun 27 '08 #3
Simple and best approach for implementing this in .Net Framework 2.0 is to
create collection of Type Generic and define the Type of the value that you
will persist. This will solve majority of the problems. Also this is good in
terms of performance.

Thanks,
Mayur H Chauhan
"rowe_newsgroups" <ro********@yahoo.comwrote in message
news:fa**********************************@m45g2000 hsb.googlegroups.com...
On May 14, 9:26 pm, "Brian" <bsgalla...@community.nospamwrote:
>I am looking for a way to store maybe in an array or dictionary... two
fields....
first field would be a string... second would be a date...
for example.. if i called up myinfo(0) it would show "the first Day"
"1/1/2008" ???
Brian

Sounds to me you just need to make a custom class that has two
properties, label and date:

//////////////
Public Class YourClassNameHere

Private _Label As String = String.Empty
Private _TheDate As DateTime = DateTime.Now

Public Sub New()

End Sub

Public Sub New(ByVal label As String, ByVal theDate As DateTime)
Me.New()

Me.Label = label
Me.TheDate = TheDate
End Sub

Public Property Label As String
Get
Return _Label
End Get
Set (ByVal value As String)
_Label = value
End Set
End Property

Public Property TheDate As DateTime
Get
Return _TheDate
End Get
Set (ByVal value As DateTime)
_TheDate = value
End Set
End Property

'// I typed this in the message so this statement might
'// not be formatted correctly
Public Overrides Function ToString() As String
Return String.Format("{0} {1}", Me.Label, Me.TheDate)
End Function

End Class
//////////////

Then you could just store these objects in any sort of IEnumerable
field (array, list, arraylist, etc) and then when you pull them out of
the array (or whatever) and call the .ToString() method, you will get
the string like you requested.

Thanks,

Seth Rowe [MVP]

Jun 27 '08 #4
Hi Seth,

Is this not more simple as it has to be in an array.

Dim myArray() as String = {"The first Day", "1/1/2008"}

I could not make more from the question of the OP.

:-)

Cor

"rowe_newsgroups" <ro********@yahoo.comschreef in bericht
news:fa**********************************@m45g2000 hsb.googlegroups.com...
On May 14, 9:26 pm, "Brian" <bsgalla...@community.nospamwrote:
>I am looking for a way to store maybe in an array or dictionary... two
fields....
first field would be a string... second would be a date...
for example.. if i called up myinfo(0) it would show "the first Day"
"1/1/2008" ???
Brian

Sounds to me you just need to make a custom class that has two
properties, label and date:

//////////////
Public Class YourClassNameHere

Private _Label As String = String.Empty
Private _TheDate As DateTime = DateTime.Now

Public Sub New()

End Sub

Public Sub New(ByVal label As String, ByVal theDate As DateTime)
Me.New()

Me.Label = label
Me.TheDate = TheDate
End Sub

Public Property Label As String
Get
Return _Label
End Get
Set (ByVal value As String)
_Label = value
End Set
End Property

Public Property TheDate As DateTime
Get
Return _TheDate
End Get
Set (ByVal value As DateTime)
_TheDate = value
End Set
End Property

'// I typed this in the message so this statement might
'// not be formatted correctly
Public Overrides Function ToString() As String
Return String.Format("{0} {1}", Me.Label, Me.TheDate)
End Function

End Class
//////////////

Then you could just store these objects in any sort of IEnumerable
field (array, list, arraylist, etc) and then when you pull them out of
the array (or whatever) and call the .ToString() method, you will get
the string like you requested.

Thanks,

Seth Rowe [MVP]
Jun 27 '08 #5
On May 15, 12:00 pm, "Cor Ligthert[MVP]" <notmyfirstn...@planet.nl>
wrote:
Hi Seth,

Is this not more simple as it has to be in an array.

Dim myArray() as String = {"The first Day", "1/1/2008"}

I could not make more from the question of the OP.

:-)

Cor

"rowe_newsgroups" <rowe_em...@yahoo.comschreef in berichtnews:fa**********************************@m 45g2000hsb.googlegroups.com...
On May 14, 9:26 pm, "Brian" <bsgalla...@community.nospamwrote:
I am looking for a way to store maybe in an array or dictionary... two
fields....
first field would be a string... second would be a date...
for example.. if i called up myinfo(0) it would show "the first Day"
"1/1/2008" ???
Brian
Sounds to me you just need to make a custom class that has two
properties, label and date:
//////////////
Public Class YourClassNameHere
Private _Label As String = String.Empty
Private _TheDate As DateTime = DateTime.Now
Public Sub New()
End Sub
Public Sub New(ByVal label As String, ByVal theDate As DateTime)
Me.New()
Me.Label = label
Me.TheDate = TheDate
End Sub
Public Property Label As String
Get
Return _Label
End Get
Set (ByVal value As String)
_Label = value
End Set
End Property
Public Property TheDate As DateTime
Get
Return _TheDate
End Get
Set (ByVal value As DateTime)
_TheDate = value
End Set
End Property
'// I typed this in the message so this statement might
'// not be formatted correctly
Public Overrides Function ToString() As String
Return String.Format("{0} {1}", Me.Label, Me.TheDate)
End Function
End Class
//////////////
Then you could just store these objects in any sort of IEnumerable
field (array, list, arraylist, etc) and then when you pull them out of
the array (or whatever) and call the .ToString() method, you will get
the string like you requested.
Thanks,
Seth Rowe [MVP]
The twist I saw was that he wanted to display both the label and the
date together, hence my ToString() override. Though you are correct,
the question was a bit vague to give an accurate answer.

Thanks,

Seth Rowe [MVP]
Jun 27 '08 #6
ok,, let me try to tell say it different way what I am wanting to do.
I want to have a collection of dates to add to the monthcalendar.boldeddates
but, I would like to list the dates I have bolded in something like a text
box.... and show that
1/1/2008 is New Years day... "New Years Day 1/1/2008"
and I'll have a list of holidays for collection...

"rowe_newsgroups" <ro********@yahoo.comwrote in message
news:ba**********************************@c58g2000 hsc.googlegroups.com...
On May 15, 12:00 pm, "Cor Ligthert[MVP]" <notmyfirstn...@planet.nl>
wrote:
>Hi Seth,

Is this not more simple as it has to be in an array.

Dim myArray() as String = {"The first Day", "1/1/2008"}

I could not make more from the question of the OP.

:-)

Cor

"rowe_newsgroups" <rowe_em...@yahoo.comschreef in
berichtnews:fa**********************************@ m45g2000hsb.googlegroups.com...
On May 14, 9:26 pm, "Brian" <bsgalla...@community.nospamwrote:
I am looking for a way to store maybe in an array or dictionary...
two
fields....
first field would be a string... second would be a date...
for example.. if i called up myinfo(0) it would show "the first Day"
"1/1/2008" ???
Brian
Sounds to me you just need to make a custom class that has two
properties, label and date:
//////////////
Public Class YourClassNameHere
Private _Label As String = String.Empty
Private _TheDate As DateTime = DateTime.Now
Public Sub New()
End Sub
Public Sub New(ByVal label As String, ByVal theDate As DateTime)
Me.New()
Me.Label = label
Me.TheDate = TheDate
End Sub
Public Property Label As String
Get
Return _Label
End Get
Set (ByVal value As String)
_Label = value
End Set
End Property
Public Property TheDate As DateTime
Get
Return _TheDate
End Get
Set (ByVal value As DateTime)
_TheDate = value
End Set
End Property
'// I typed this in the message so this statement might
'// not be formatted correctly
Public Overrides Function ToString() As String
Return String.Format("{0} {1}", Me.Label, Me.TheDate)
End Function
End Class
//////////////
Then you could just store these objects in any sort of IEnumerable
field (array, list, arraylist, etc) and then when you pull them out of
the array (or whatever) and call the .ToString() method, you will get
the string like you requested.
Thanks,
Seth Rowe [MVP]

The twist I saw was that he wanted to display both the label and the
date together, hence my ToString() override. Though you are correct,
the question was a bit vague to give an accurate answer.

Thanks,

Seth Rowe [MVP]

Jun 27 '08 #7
The shortest way I now with one row

\\\\
dim dt as new datatable
dim dcfirstcolumn as new datacolumn("first")
dim dcsecondcolumn as new datacolumn("second")
dt.colums.add(dcfirstcolumn)
dt.colums.add(dcsecondcolumn)
dim dr as new datarow = dt.rows.newrow
dr(dcfirstcolumn) = "The first Day"
dr(dcsecondcolumn) = "1/2/2008"
dt.rows.add(dr)
myListBox.DataSource = dt
myListBox.DisplayMember = "first"
myListbox.ValueMember = "second"
///

Typed in this message so watch errors.

Cor

"Brian" <bs********@community.nospamschreef in bericht
news:uK**************@TK2MSFTNGP03.phx.gbl...
ok,, let me try to tell say it different way what I am wanting to do.
I want to have a collection of dates to add to the
monthcalendar.boldeddates
but, I would like to list the dates I have bolded in something like a text
box.... and show that
1/1/2008 is New Years day... "New Years Day 1/1/2008"
and I'll have a list of holidays for collection...

"rowe_newsgroups" <ro********@yahoo.comwrote in message
news:ba**********************************@c58g2000 hsc.googlegroups.com...
>On May 15, 12:00 pm, "Cor Ligthert[MVP]" <notmyfirstn...@planet.nl>
wrote:
>>Hi Seth,

Is this not more simple as it has to be in an array.

Dim myArray() as String = {"The first Day", "1/1/2008"}

I could not make more from the question of the OP.

:-)

Cor

"rowe_newsgroups" <rowe_em...@yahoo.comschreef in
berichtnews:fa********************************** @m45g2000hsb.googlegroups.com...

On May 14, 9:26 pm, "Brian" <bsgalla...@community.nospamwrote:
I am looking for a way to store maybe in an array or dictionary...
two
fields....
first field would be a string... second would be a date...
for example.. if i called up myinfo(0) it would show "the first Day"
"1/1/2008" ???
Brian

Sounds to me you just need to make a custom class that has two
properties, label and date:

//////////////
Public Class YourClassNameHere

Private _Label As String = String.Empty
Private _TheDate As DateTime = DateTime.Now

Public Sub New()

End Sub

Public Sub New(ByVal label As String, ByVal theDate As DateTime)
Me.New()

Me.Label = label
Me.TheDate = TheDate
End Sub

Public Property Label As String
Get
Return _Label
End Get
Set (ByVal value As String)
_Label = value
End Set
End Property

Public Property TheDate As DateTime
Get
Return _TheDate
End Get
Set (ByVal value As DateTime)
_TheDate = value
End Set
End Property

'// I typed this in the message so this statement might
'// not be formatted correctly
Public Overrides Function ToString() As String
Return String.Format("{0} {1}", Me.Label, Me.TheDate)
End Function

End Class
//////////////

Then you could just store these objects in any sort of IEnumerable
field (array, list, arraylist, etc) and then when you pull them out of
the array (or whatever) and call the .ToString() method, you will get
the string like you requested.

Thanks,

Seth Rowe [MVP]

The twist I saw was that he wanted to display both the label and the
date together, hence my ToString() override. Though you are correct,
the question was a bit vague to give an accurate answer.

Thanks,

Seth Rowe [MVP]

Jun 27 '08 #8

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

Similar topics

4
by: Frank Millman | last post by:
Hi all I need to generate potentially large reports from a database, and I want to offer the option of print preview before actually printing (using wxPython). I figure that the best way to...
5
by: great_googley_moogley | last post by:
Greetings, I am in the process of installing a SQL database at a customer location. I have determined that there are 3 ways to do this, and I wanted to know which is the best of the 3. 1...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
9
by: Frances | last post by:
Hi All, * PREMISE * I'm creating an Access form with 150 items subdivided into 20 categories. Multiple categories (and items) can be selected so my user wants checkboxes. All of the options...
0
by: Anonieko Ramos | last post by:
ASP.NET Forms Authentication Best Practices Dr. Dobb's Journal February 2004 Protecting user information is critical By Douglas Reilly Douglas is the author of Designing Microsoft ASP.NET...
45
by: Summercoolness | last post by:
it seems that range() can be really slow: the following program will run, and the last line shows how long it ran for: import time startTime = time.time() a = 1.0
5
by: csgraham74 | last post by:
Hi guys, Basically i have been developing in dotnet for a couple of years but ive had a few issues in regards to error handling. For example - I have a class that i call passing in a stored...
9
by: Paul | last post by:
Hi, I feel I'm going around circles on this one and would appreciate some other points of view. From a design / encapsulation point of view, what's the best practise for returning a private...
1
by: Muchach | last post by:
Hello, Ok so what I've got going on is a form that is populated by pulling info from database then using php do{} to create elements in form. I have a text box in each table row for the user to...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.