473,386 Members | 1,621 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.

ArrayLists

Hi can anyone help me answer a few questions regarding arralists

1) If i add numerous intergers to an arraylist (i.e 4, 1 ,7, 23, 4, 2) how would i retrieve the INDEX of the value that is the smallest

2) When i set the datasource property of a datagrid to an arraylist containing the list of integers no values are shown in my datagrid. The correct number of rows seem to appear everytime but i just dont get the values showing!
When i changed the datasource to a different arraylist containg Dates, i do not get the dates displayed but instead i get a column that has the title 'length'. The value of this column is always 10. i presume this means the length of the date value (i.e 02/04/2004 = length of 10)!!! Once again the correct number of rows are shown but they contain the value 10 instead of the actual date!!!
Does anyone know what im doin wrong?
I add to the arraylist like
Dim Variable1 as Int32 = CInt(Textbox1.text
Arraylist.Add(Variable1

If anyone can help me on any of these answersit would be appreciated.
Jul 21 '05 #1
3 1273
function GetIndexOfSmallestNumber(arraylist a) as int
int nSmallestValue = a.Item(0)
int nSmallestIndex = 0
for n = 1 to a.Count-1
if a.Item(n) < nSmallestValue then
nSmallestIndex = n
nSmallestValue = a.Item(n)
end if
next n
return nSmallestIndex
"Hi I" <an*******@discussions.microsoft.com> wrote in message
news:1E**********************************@microsof t.com...
Hi can anyone help me answer a few questions regarding arralists?

1) If i add numerous intergers to an arraylist (i.e 4, 1 ,7, 23, 4, 2) how would i retrieve the INDEX of the value that is the smallest?
2) When i set the datasource property of a datagrid to an arraylist containing the list of integers no values are shown in my datagrid. The
correct number of rows seem to appear everytime but i just dont get the
values showing!! When i changed the datasource to a different arraylist containg Dates, i do not get the dates displayed but instead i get a column that has the title
'length'. The value of this column is always 10. i presume this means the
length of the date value (i.e 02/04/2004 = length of 10)!!! Once again the
correct number of rows are shown but they contain the value 10 instead of
the actual date!!! Does anyone know what im doin wrong??
I add to the arraylist like:
Dim Variable1 as Int32 = CInt(Textbox1.text)
Arraylist.Add(Variable1)

If anyone can help me on any of these answersit would be appreciated.

Jul 21 '05 #2
.
i Tried the code that u provided me but i have encountered a few problems. This is what i tried..

function GetIndexOfSmallestNumber(arraylist a) as int3
Dim nSmallestValue As Int3
Dim nSmallestIndex As Int3

CInt(nSmallestValue = a.Item(0)
nSmallestIndex =
For i = 1 To a.Count -
If a.Item(i) < nSmallestValue The
nSmallestIndex =
nSmallestValue = a.Item(i
End I
Next
Return nSmallestInde

The pronlem is that all the 'a' are underlined. When i hover over it i get the error message that states
'A' is not accessible in this content because it is 'Private'

How can i fix this problem
Also how would i call this function when i want to run this code?
As u guessed im new to the world of VB.NET

Jul 21 '05 #3
On Tue, 2 Mar 2004 04:26:07 -0800, . wrote:
i Tried the code that u provided me but i have encountered a few problems. This is what i tried...

The pronlem is that all the 'a' are underlined. When i hover over it i get the error message that states:
'A' is not accessible in this content because it is 'Private'.

You're mixing C# and VB Syntax. Try this:

Public Function GetIndexOfSmallestNumber(a As ArrayList) As Int32
Dim nSmallestValue As Int32
Dim nSmallestIndex As Int32

nSmallestValue = CInt(a.Item(0))
nSmallestIndex = 0
For i = 1 To a.Count - 1
If a.Item(i) < nSmallestValue Then
nSmallestIndex = i
nSmallestValue = a.Item(i)
End If
Next
Return nSmallestIndex
End Function
Also how would i call this function when i want to run this code??
As u guessed im new to the world of VB.NET.


Call it with code similar to this:

Dim MyArrayList As New ArrayList

'Code to add items to the array list here

Dim iSmallestIndex As Int32 = GetIndexOfSmallestNumber(MyArrayList)


--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.
Jul 21 '05 #4

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

Similar topics

0
by: Brandon Potter | last post by:
Trying to find the best way to find common entries in an x number of ArrayLists or arrays of integers. Curious if there is a method already available in .NET to do just this very thing. ...
0
by: James | last post by:
I see that variations on this question have appeared before but I'm still completely stumped. I'm developing an application with a fairly robust graphics component for 3D rendering. I've written...
1
by: godsella | last post by:
First i have two stored procedures, i have passed the values of each one into two different arraylists of dates. how can i compare the two arraylists of dates? Thanks in advance
5
by: drdave | last post by:
I would like to have ten arraylists created within a loop.. is there a conversion or something I can do to acheive this.. pseudo: Dim counter As Integer = 0 Dim ArrName As ArrayList ...
0
by: steve | last post by:
I'm looking for a code example how to compare the values in a given record in different arraylists two arraylists, two fields in each record, both defined as string I'm thinking that it's...
3
by: steve | last post by:
I need to compare the value of a field in a row on an arraylist with the value of a field on a second arraylist I have this bit of code working for arrays but cant get it working for arraylists The...
4
by: Andy in S. Jersey | last post by:
I would like to create an unknown number of Arraylists, meaning, I don't know how many I should create until runtime. I will be reading a table, and 0,1,2, or more fields have to be put into...
2
by: Andy in S. Jersey | last post by:
I would like to create an unknown number of ArrayLists, that is I don't know that until runtime. Of course I can do this if I knew I needed two: ArrayList IntervalArray1 = new ArrayList();...
1
by: Newbie19 | last post by:
I'm just learning java arrays/arraylists and was wondering what are the best books for learning java arrays/arraylists? I know practice is the best way to learn, but I have a hard time...
3
by: =?Utf-8?B?Sm9zaFA=?= | last post by:
Hi All, I am attempting to compare values in two arraylists to make sure all the values are the same. I am running into trouble with my code if both arraylists compare okay up until a point and I...
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: 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
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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
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.