I have a seq. file with some blank lines (CrLf only) in it. When the line
is read, I get a value of "Nothing" returned, which give me an "End of File"
condition, so I terminate my procedure.
How do you get around interspersed blank lines?
TIA,
Larry Woods 4 3578
Larry, I have a seq. file with some blank lines (CrLf only) in it. When the line is read, I get a value of "Nothing" returned, which give me an "End of File" condition, so I terminate my procedure.
You probably have code similar to this
Dim line As String = yourStreamReade r.ReadLine()
Do Until line = Nothing
...
line = yourStreamReade r.ReadLine()
Loop
The problem is that (line = Nothing) evaluates to True for empty
strings as well. Change it to
Do Until line Is Nothing
Mattias
--
Mattias Sjögren [MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
You are soooo right. Thanks much. Any possibility you could give me a hint
on where I would have found that in the VB doc? I "thought" that I had
looked everywhere!
TIA,
Larry Woods
"Mattias Sjögren" <ma************ ********@mvps.o rg> wrote in message
news:uR******** *****@TK2MSFTNG P12.phx.gbl... Larry,
I have a seq. file with some blank lines (CrLf only) in it. When the
lineis read, I get a value of "Nothing" returned, which give me an "End of
File"condition, so I terminate my procedure.
You probably have code similar to this
Dim line As String = yourStreamReade r.ReadLine() Do Until line = Nothing ... line = yourStreamReade r.ReadLine() Loop
The problem is that (line = Nothing) evaluates to True for empty strings as well. Change it to
Do Until line Is Nothing Mattias
-- Mattias Sjögren [MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ Please reply only to the newsgroup.
Hello,
"Larry Woods" <la***@lwoods.c om> schrieb: I have a seq. file with some blank lines (CrLf only) in it. When the line is read, I get a value of "Nothing" returned, which give me an "End of File" condition, so I terminate my procedure.
How do you get around interspersed blank lines?
\\\
Imports System.IO
..
..
..
Dim sr As New StreamReader("C :\WINDOWS\WIN.I NI")
Dim strLine As String
strLine = sr.ReadLine()
Do Until strLine Is Nothing
MsgBox(strLine)
strLine = sr.ReadLine()
Loop
sr.Close()
///
HTH,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET http://www.mvps.org/dotnet
Hi Larry,
Nothing is not just the equivalent of a null pointer. It means the default
value for the type in question.
In the case of an object that will be a null pointer. Strings, however,
while being objects, are treated as a special case.
|| if sSomeString = Nothing
The sSomeString in this context is the string contents and the Nothing is
the default for string contents, ie "".
|| if sSomeStringVar Is Nothing
The sSomeStringVar in this context is the pointer to string contents and
the Nothing is the default for objects which is null pointer.
To have understood this you would have had to have read the sections on
Nothing, Strings, Expressions and a couple of other topics, I'm sure. You may
well have read all these areas, but often an understanding of any one help
topic relies on making connections from other topics, plus a bit of fiddling
about with code, plus a bit of asking other people. Which you've just done.
:-)
Regards,
Fergus This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: m. verkerk |
last post by:
Hi everybody!
Hope someone can help me out with this!
I'm sending a file to a user with the following code:
header( "Content-Type: application/binary");
header( "Content-disposition: attachment; filename=$filename");
header( "Content-Transfer-Encoding: binary" );
passthru( "svnadmin dump ".$svn_repos_loc."/".$name );
|
by: Ruben |
last post by:
Hello.
I am trying to read a small text file using the readline statement. I
can only read the first 2 records from the file. It stops at the blank
lines or at lines with only spaces. I have a while statement checking
for an empty string "" which I understand represents an EOF in Python.
The text file has some blank lines with spaces and other with blanks.
Thanks a lot.
|
by: JackRazz |
last post by:
Anyone know the regular expression to match a blank line where the byte sequence is
"0D 0A 0D 0A"
ive tried "\r\n\r\n+", "^$+" "\n\r" with no success. Any Ideas?
Thanks - JackRazz
This is the code fragment I'm trying
Dim r As Regex, m As Match, i As Integer
|
by: Hallvard B Furuseth |
last post by:
I'm trying to clean up a program which does arithmetic on text
file positions, and also reads text files in binary mode. I
can't easily get rid of it all, so I'm wondering which of the
following assumptions are, well, least unportable.
In particular, do anyone know if there are real-life systems
where the text file assumptions below don't hold?
For text mode FILE*s,
|
by: mazwolfe |
last post by:
Someone recently asked about reading lines. I had this code written
some time ago (part of a BASIC-style interpreter based on H. Shildts
in Art of C) to read a file with the lines ended in any format:
Microsoft-style CR/LF pair, Unix-style NL, or Mac-style CR. It also
allows for EOF that does not follow a blank line. I thought this would
make text-file sharing a bit easier.
Here it is:
/* Load a file, normalizing newlines to *nix...
| |
by: lihao0129 |
last post by:
Hi, folks:
I recently went through a strange problem with my Javascript code,
say: I have a string variable which are from a 'textarea' element and
I want to remove the trailing newlines inside the string. I am using
something like the following:
var txt = textarea_element.value.replace(/\n*$/, '');
But this replaced only the last newline(by changing '' to 'K', and
|
by: lstanikmas |
last post by:
Hi, I'm validating a form with this ASP but receiving some blank email
responses; does anyone see anything wrong with it?:
function isFormVarExcluded(thisForm, strToCheck)
{
var strExcludeVars = thisForm.elements.value;
var arrExcludeVars = strExcludeVars.split(",");
for (var j=0; j<arrExcludeVars.length; j++)
{
if (arrExcludeVars == strToCheck) return true;
|
by: tmallen |
last post by:
I'm parsing some text files, and I want to strip blank lines in the
process. Is there a simpler way to do this than what I have here?
lines = filter(lambda line: len(line.strip()) 0, lines)
Thomas
|
by: Lelu |
last post by:
Hi, My HTML form is generating some blank email
responses; does anyone see anything wrong with the scripts?:
function isFormVarExcluded(thisForm, strToCheck)
{
var strExcludeVars = thisForm.elements.value;
var arrExcludeVars = strExcludeVars.split(",");
for (var j=0; j<arrExcludeVars.length; j++)
{
if (arrExcludeVars == strToCheck) return true;
|
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: 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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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: 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: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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...
| |