below is some codes.
my arraylist below reads from a file. My files contains blank line (ie
carriage return)
My message dialog shows all strings being captured. However i do not want my
array to contain "blank" string/line/carriage return
How do i remove the index so that my arraylist become smaller ?
*************** *************
Dim sr As StreamReader = New StreamReader(fi lespath)
Dim line As String
Do
line = sr.ReadLine
'add each line into arraylist
If InStr(line, ";") <> 1 Then
filestoexecute. Add(line)
End If
Loop Until line Is Nothing
sr.Close()
*************** **************
For Each i In filestoexecute
MessageBox.Show (i)
Next
*************** ************* 2 6519
"James" <jk****@hotmail .com> wrote in message
news:es******** ******@TK2MSFTN GP12.phx.gbl... my arraylist below reads from a file. My files contains blank line (ie carriage return)
.. . . How do i remove the index so that my arraylist become smaller ?
So you're trying to leave out blank lines and comments?
If InStr(line, ";") <> 1 Then
If the line is blank, Instr() will return 0, which isn't 1, so will add the
line.
To exclude blank lines as well (if I can remember the "old" syntax for
this),
try this :
If Len( line ) > 0 _
AndAlso Instr( line, ";" ) <> 1 _
Then
(BTW, using the methods on the String class, thios would be)
If line.Length > 0 _
AndAlso Not line.StartsWith ( ";" ) _
Then
HTH,
Phill W.
"James" <jk****@hotmail .com> schrieb: my arraylist below reads from a file. My files contains blank line (ie carriage return)
My message dialog shows all strings being captured. However i do not want my array to contain "blank" string/line/carriage return
How do i remove the index so that my arraylist become smaller ? [...] Do
line = sr.ReadLine
'add each line into arraylist
If InStr(line, ";") <> 1 Then
\\\
If Len(line) > 0 AndAlso InStr(line, ";") <> 1 Then
...
End If
///
If you want to check the string with spaces on the right and left end of the
string, use 'Len(Trim(line) ) > 0'.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: steve smith |
last post by:
Hi I'm still having some problems getting my head round this language.
A couple of things don't seem to work for me. First I am trying to
obtan a count of the number of words in a sting, so am using the split
function with ' ', but how do i get it to take into account
punctuation marks such as ',',',' etc?
Also I am then trying to add contents of an array of strings to an
arraylist, but only if the string isn't already there. I was using...
|
by: Franck Diastein |
last post by:
Hi, I'm trying to remove items from a collection this way:
foreach(Object myO in ObjectCol){
if(myO != "xxx"){
myO.Remove();
}
}
But I'm having an error telling me that Collection was modified... I
understand this, since I remove one object from collection...
|
by: Don |
last post by:
My user control has a combobox with an arraylist attached to it along with custom add and remove methods.
The "Add" method is working great. However I don't understand why the "Remove" method isn't working. It neither removes the item from the arraylist nor from the combobox like it's supposed to do.
A couple of notes: cbx is the name of the combobox within my usercontrol, file is the name of the arraylist within my usercontrol. To try...
|
by: Ryan Liu |
last post by:
Hi,
What does ArrayList.Synchronized really do for an ArrayList?
Is that equal to add lock(this) for all its public methods and properties?
Not just for Add()/Insert()/Remvoe()/Count, but also for Item (this)?
Normally,do I need sync at all? Isn't that true without sync the program can
run faster?
|
by: Extremest |
last post by:
I have a loop that is set to run as long as the arraylist is > 0.
at the beginning of this loop I grab the first object and then
remove it. I then go into another loop that checks to see if there
are more objects that match the first object that i grabbed. If
they match then I put them in an array. I would like to remove each
match from the arraylist as I find them to speed things up and so
that they don't get checked again. If I try...
| |
by: Olveres |
last post by:
Hi,
I have managed to work out how to add new lines into a calculated text
box. However in this text box some of the outcome fields are empty
however when previewing the report it includes the blank fields, so
each section of the report is the same size, my field is set to can
grow/shrink, but I think my inclusion in the code for the calculated
box of all 15 outcomes (I have no choice) is what's causing each
calculated box to be the...
|
by: pamelafluente |
last post by:
Hi
I have a sorted list with several thousands items. In my case, but this
is not important, objects are stored only in Keys, Values are all
Nothing. Several of the stored objects (might be a large number) have
to be removed (say when ToBeRemoved = true).
class SomeObj
ToBeRemoved be a boolean field
end class
|
by: =?Utf-8?B?YmJn?= |
last post by:
Hi all,
I wanted to go through each entry(?) of ArrayList and remove some particular
entry. So I tried following but it throws exception at runtime:
foreach (myEntry entry in myArrayList)
{
// do something...
if (entry.fieldA == 0)
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |