473,386 Members | 1,630 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,386 software developers and data experts.

Different object name for each object

This clas creates new movie.

--------------CODE--------------
Public Class AllMovies
Sub New(ByVal MovieName As String, ByVal MovieLenght As Integer)
Movie = MovieName
Lenght = MovieLenght
End Sub
Public Movie As String
Public Lenght As String
End Class
-----------END CODE-------------

Then I use Click event of the button to create object and add it to
ArrayList.

--------------CODE--------------
Private Sub AddMovie_Click(...) Handles AddMovie.Click
Dim movie As AllMovies = New AllMovies(TextBox1.Text, TextBox2.Text)
MovieCollection.Add(movie)
End Sub
-----------END CODE-------------

Is there any way I could name the new object As movie1, movies2, movie3 and
so on. Right now all of my on+bjects in ArrayList are called movie.
Nov 21 '05 #1
5 1005
Do you wish to refer to your object by a certain name? You can add
them to a hash table instead of an arraylist and then assign a name as
the "Key".

Or you can add a Name property to your class and assign the name when
you create the object.

What do you need to do with the name?

Nov 21 '05 #2

"Chris Dunaway" <du******@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Do you wish to refer to your object by a certain name? You can add
them to a hash table instead of an arraylist and then assign a name as
the "Key".

Or you can add a Name property to your class and assign the name when
you create the object.

What do you need to do with the name?


I need to use IndexOf in my arraylist.
Nov 21 '05 #3
You could use the HashTable and add movies like this:

MovieCollection.Add("Movie1",movie)

and then later access the movie using:

Dim m As AllMovies = MovieCollection("Movie1")

or to see if the MovieCollection had a certain movie, you could use
this:

If MovieCollection.ContainsKey("Movie1") Then
MsgBox("Found the movie!")
End If

Hope this helps a little

Nov 21 '05 #4

"Chris Dunaway" <du******@gmail.com> wrote in message
news:11**********************@l41g2000cwc.googlegr oups.com...
You could use the HashTable and add movies like this:

MovieCollection.Add("Movie1",movie)

and then later access the movie using:

Dim m As AllMovies = MovieCollection("Movie1")

or to see if the MovieCollection had a certain movie, you could use
this:

If MovieCollection.ContainsKey("Movie1") Then
MsgBox("Found the movie!")
End If

Hope this helps a little


Thanks, I'll rewrite my app like you suggested. What's the point of IndexOf
if you can't use it when you create a program in a way I did?
Nov 21 '05 #5
If you had an instance of an object and wanted to see if that object
was already in the arraylist you could use indexof. Or if you wanted
to prevent adding the same object more than once.

Nov 21 '05 #6

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

Similar topics

2
by: Sergey Ilinsky | last post by:
Well, I've been working with JS for three years and have a great experience here. But! I still have no really acceptable answer to the following question: What is the principle difference between...
20
by: xixi | last post by:
hi, we use db2 udb v8.1 on windows, i am trying to use federated database objects to create wrapper, even though i have update dbm cfg using federated yes, i still get error "the instance for the...
7
by: xzzy | last post by:
I need to automate a report in a different database (and thank yous to Terry Kreft for pointing me in the right direction). below is the code with the one line that does not work, marked: 'Does...
1
by: Chasing Gates | last post by:
I have created a database that brings in a new table weekly. I then made a separate query for each sales rep and a separate report for each rep. (The reports are all identical but call different...
8
by: TTroy | last post by:
I have a few questions about "scope" and "visibility," which seem like two different things. To me "visibility" of the name of a function or object is the actual code that can use it in an...
2
by: sal | last post by:
Greets, all I'm trying to create different multiple mailing type labels on a page reading from an untyped dataset anyone have any ideas on how I can get this done without crystal reports a plan...
17
by: romixnews | last post by:
Hi, I'm facing the problem of analyzing a memory allocation dynamic and object creation dynamics of a very big C++ application with a goal of optimizing its performance and eventually also...
2
by: mast2as | last post by:
Hi there, for a long time I've been trying to think of way of saving different data of different types using one single class (well 2 in reality, a class for the data, and 1 class for a list of...
46
by: Phil Reynolds | last post by:
I have Access 2000 and 2003 on my development machine. My client only has Access 2000. When I develop for this client, I run Access 2000. However, my code requires that I have the Microsoft Word...
7
by: WTH | last post by:
I am now aware (I am primarily a C++ developer) that in C# if you reference the same interface from the same file in two different projects the types are actually incompatible. I found this out...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
jinu1996
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...

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.