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

Newbee: questions on array

Hi all,

can anyone tell me how i can find out if an array is empty?
i want to code an if statment that loops through an array only if it is not empty.
I have been trying
if not (CarArray1 is nothing) then

but this doesnt work. I was told to use the count, but it doesnt like my coding
if CarArray1.count >0 then

Can anyone advise me?

Also, How do i clear the items in an array?
CarArray1.clear ????

As u can see i just guessing the coding :o)
thank u

Nov 22 '05 #1
4 1087
Cor
Hi Varun,

I thought a array can never be empty only if you declare it as
dim myarray() as array
But then it is almost useless.

But mostly you can see if there are no items in an array with

if myarray.length = 0

In the above example this wil throw an error

If you have declared it as
dim myarray() as array = {} than it had given the result you want.

In the first situation, you could have done

If myarray Is Nothing because there was no array.

But in my opinion is with this type of arrays this is useless coding,
because you know the length of the array.

So look what type of array you use and when you want it dynamical, have a
look for "arraylist".

I hope this helps,
can anyone tell me how i can find out if an array is empty?
i want to code an if statment that loops through an array only if it is not empty.
I have been trying
if not (CarArray1 is nothing) then

but this doesnt work. I was told to use the count, but it doesnt like my coding if CarArray1.count >0 then

Can anyone advise me?

Also, How do i clear the items in an array?
CarArray1.clear ????

As u can see i just guessing the coding :o)
thank u

Nov 22 '05 #2
I have declared my array with coding from example from the interne
Dim CarArray(10) As strin

What i have done is added the values to my array
i.e Mustang, Ford etc
What i want is to now remove all the values that are in my array when user clicks a button

Is this not possible
What is difference between arraylist and normal array. I asked my friend and he said there is no difference!?

Thank you for help

Nov 22 '05 #3
Cor
Hi Varun,

Here a very small sample
\\\
Dim myArray As New ArrayList
myArray.Add("Peugeot")
myArray.Add("Ferari")
myArray.Add("Fiat")
myArray.Add("Renault")
myArray.RemoveAt(0)
myArray.Insert(1, "Mercedes")
myArray.Clear()
///

I hope this helps,

Cor
Nov 22 '05 #4
Thank you for coding example. this is very kind of you. I will try it and read up on arraylist. If i have any difficulties i will message back again
Nov 22 '05 #5

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

Similar topics

8
by: sikka noel | last post by:
Hi guyz, I rencenly finished by college book on c++. I have done data structures & operating systems as well. I thought that at this point i know C++ completely. However when I go on internet...
4
by: Varun | last post by:
Hi all, can anyone tell me how i can find out if an array is empty? i want to code an if statment that loops through an array only if it is not empty. I have been trying if not (CarArray1...
1
by: Claude Vernier | last post by:
Hi, I already got a nice Web application running and need to adapt it for iPaqs, Smartphone and Blackberry. Can you suggest a better newsgroup if any and some links to find best practices and...
3
by: Ross | last post by:
Hi I have bought the book 'Zen of CSS Design' but need some basic tips or links to start me off. I only have basic knowledge where I have set up styles in dreamwever like this ..this_style
4
by: cmc | last post by:
I need some clarification to help me understand the DB2 strucure more. The questions are about "implicit schema" 1. This is a very interest concpet that DB2 let every user to create new schema...
4
by: PerryC | last post by:
All, 1. Do the following codes seem ok? 2. If so, then how do I pull the value of YOE1 and YOE2 into my report? (to do some further calculations) ...
1
by: Danny Ni | last post by:
Hi, I have questions: (1) To establish web garden, a machine must have mutiple processors. Right? (2) To use ASP.Net session in a web garden environment, process model must be out-of-process,...
2
by: Jonny | last post by:
Hiya all Using: ASP.NET Version 1.1 I am learning ASP.NET & would like to know:- How do I add a Open Browser Dialog behind a server button & validate a chosen file as a new e-mail...
4
by: Christian Maier | last post by:
Hi After surfing a while I have still trouble with this array thing. I have the following function and recive a Segmentation fault, how must I code this right?? Thanks Christian Maier
0
by: Martin Arvidsson, Visual Systems AB | last post by:
Hi! I have a couple of newbee questions. I have a .aspx page with a couple of TextBoxes and a submit button. Now... When i press the submitbutton i want the data in the TextBoxes to be...
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: 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...
0
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...

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.