Checking for A Blank String

T

Tom Leylan

Herfried K. Wagner said:
I know the meaning of "robust". The whole discussion is now about using
'Len' vs. 'String.IsNullOrEmpty'. It's pretty clear that the shortest
solution is not always the most robust one. However, I do not see the
relation to my preference of 'Len'. 'Len' is faster to type and read and
I do not consider it less robust than 'String.IsNullOrEmpty'.

Okay but you wrote "whatever that means" and I can't read minds. This isn't
a discussion about Herfried's preferred syntax that is a given. If it was
available in VB6 Herfried prefers to use it in VB.Net. I understand that
along with your reasons I am addressing those who are on the fence. Those
who may not consider themselves VB gurus and who might one day like to
develop software (and be employable) in more than one language.
Well, then I suggest you specify more clearly what you are talking about.

Got it... I'm to blame when you attempt to restate what I wrote and I'm to
blame when you write "Why should using 'Len' be "less robust" (whatever that
means)?" We've been through this before. You're playing a debate game if
you want to win the debate you win. I'm not debating with VB-gurus about
application development.
Where's the relation to the topic?

What is being discussed is "preferences" and I'm trying to point out (and
you will to somebody else in another thread shortly I'm sure) one's
preferences are related to what one does. If you haven't worked in a large
group or haven't had to maintain a large project or haven't been responsible
for the distribution of large quantities of software your personal choices
are made based on a criteria which may not be shared.

To offer your own personal preference if it is based upon the experience of
working at home on small apps to somebody who is setting up team-based
coding standards without considering the impact is rude if nothing else.
Then I am wondering how you are writing code at all.

And I am wondering if you have ever worked as a software developer :)
Hm... This point was intended as a joke. No, I really do /not/ think
this is a valid reason not to use 'String.IsNullOrEmpty', as I do not see
the naming and behavior as a reason for abandoning it from the toolbox.

In the words of Herfried: "Well, then I suggest you specify more clearly
what you are talking about."
I gave the reasons why I prefer 'Len' over 'String.IsNullOrEmpty' in my
previous post.

Actually what you did (and anybody can check it) is describe one solution as
"brilliant" and one as "stupid" using the well-worn screwdriver/hammer
analogy so as to avoid those words. Anybody can write "that's like..." and
proceed to make up something which it isn't like. Again you want to win the
debate rather than discuss the issue.
I do not want to win anything. It seems that you see discussions as
fights instead of what they are -- just discussions. Be assured that I
know that many developers don't have much knowledge about the tools they
are using. However, as I said, there is no problem 'Len' has and
'String.IsNullOrEmpty' doesn't have.

In the words of Herfried: "Well, then I suggest you specify more clearly
what you are talking about."

If it isn't a fight in your mind then why have you boiled the reasons down
to the length of the command? There isn't a command on Earth that I have
bemoaned typing due to my lack of time to type it or the pain and suffering
I incurred doing it.
These points are all ungrounded prejudices, none of them apply. I am
actually using different programming languages and I prefer use the tools
they provide. The .NET Framework's method has been considered "low-level"
because the VB.NET class library and other libraries are built on top of
the .NET Framework's classes, often providing access on a higher level, as
.NET programming languages like VB.NET and C# do over IL.

You have categorized them as "low-level" and perhaps a few others do but
that doesn't make them so.
At least to me as a non-native English speaker this means the same.

You understand the difference between buying (for instance) a Sony TV which
develops a problem and proclaiming "Sony TVs suck" and the statement "I
bought a Sony once and it had a problem."
If there are two ways to archieve a certain thing and one of them is
faulty, why choose the faulty one? It seems that your decisions are much
more based on ideology than mine. I use 'Len' because there are problems
attached with another way to archieve the same thing and you are wrongly
extrapolating that to a general preference of VB's functions over the .NET
Framework.

My decisions are based upon an ideology without a doubt. That ideology is
one that I have developed over the course of 30 years of software
development. It is not based upon the language I used or the length of a
command. When Clipper (a dBASE-language) introduced the radically changed
5.0 version I suggested that people make the switch because as radical as it
was it solved many of the nagging problems introduced by the dBASE language.
One's software would be safer, more robust, probably tighter and far less
ambiguous. On the other hand it would tend to less-well understood by dBASE
developers but better understood by Pascal and C developers and of course by
any Clipper developer who could see how much of an improvement the new
version was.

Without a rational ideology it's only about defending one's turf. I'll
suggest that is why the VB6 diehards feel threatened by everything and
anything that isn't VB6.
I 100 % agree, but this even includes using the tools VB provides over the
tools of the .NET Framework if their use has advantages.

Does the shop you work in use VB.Net exclusively? Is anything there written
in C#?
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Herfried said:
Göran,



DANGER ! String.IsNullOrEmpty can lead to runtime Null exceptions !!


Because 'String.IsNullOrEmpty' can lead to potential problems at
runtime. I am not saying that 'String.IsNullOrEmpty' should never be
used under all circumstances.

Have you tried the same using the Len method? The implementation of
IsNullOrEmpty and Len are quite similar, so I see no reason why the Len
method should not be subject to the same bug.

The fact that the bug was discovered using the IsNullOrEmpty method,
doesn't make that method any more problematic than any other method. You
are confusing the patient with the disease.
 
?

=?windows-1252?Q?G=F6ran_Andersson?=

Herfried said:
Re-read my post. I gave a technical reason why I am preferring 'Len' in
this particular case.

I have reread your post, and I can find no reason for such a misleading
analogy.
 
H

Herfried K. Wagner [MVP]

Tom,

Tom Leylan said:
Okay but you wrote "whatever that means" and I can't read minds. This
isn't a discussion about Herfried's preferred syntax that is a given.

This is not a discussion about basing preferences on ideology. I have given
technical reasons why I avoid using 'String.IsNullOrEmpty' currently.
If it was available in VB6 Herfried prefers to use it in VB.Net.

Again, completely wrong. Although I am currently only active in the English
VB group, I use VB.NET, VB6, C#, and some other programming languages
equally. When using VB.NET, I use VB.NET, not only the .NET Framework, as I
do with other programming languages.
I understand that along with your reasons I am addressing those who
are on the fence. Those who may not consider themselves VB gurus

It's not me who would consider me a "VB guru" (I always hated this term
because it implies that somebody is inerrant).
and who might one day like to develop software (and be
employable) in more than one language.

Again I do not see the relation to the topic because nobody claims that
he/she "speaks" VB only.
What is being discussed is "preferences" and I'm trying to point out (and
you will to somebody else in another thread shortly I'm sure) one's
preferences are related to what one does. If you haven't worked in a
large group or haven't had to maintain a large project or haven't been
responsible for the distribution of large quantities of software your
personal choices are made based on a criteria which may not be shared.

Nobody is doubting that.
To offer your own personal preference if it is based upon the experience
of working at home on small apps to somebody who is setting up team-based
coding standards without considering the impact is rude if nothing else.

As I said already, I don't want to fight a battle here wo of us is the real
"guru", and as always I won't go down to the personal level. However, I
take my right to state and substantiate my preferences.
And I am wondering if you have ever worked as a software developer :)


In the words of Herfried: "Well, then I suggest you specify more clearly
what you are talking about."

Tom, in contrast to you I do not blame you for making mistakes. Everybody
makes them, I make them and even you make them.
Actually what you did (and anybody can check it) is describe one solution
as "brilliant" and one as "stupid" using the well-worn screwdriver/hammer
analogy so as to avoid those words. Anybody can write "that's like..."
and proceed to make up something which it isn't like. Again you want to
win the debate rather than discuss the issue.

I wrote:

| Trying to avoid the use of VB's intrinsic functions is like trying to use
a
| screwdriver to screw in a nail although there is a hammer in the toolbox
for
| the reason that "a screwdriver is a more professional tool than a hammer."

I want to add "... VB's intrinsic functions for the sake of avoiding it...",
because it seems that this is not clear from reading my post.
You have categorized them as "low-level" and perhaps a few others do but
that doesn't make them so.

It seems that you negatively connotate the term "low-level", which is not
what I do.
You understand the difference between buying (for instance) a Sony TV
which develops a problem and proclaiming "Sony TVs suck" and the statement
"I bought a Sony once and it had a problem."

Does that really matter here? If there are problems associated with the
function, regardless of their actual reason, why would I want to prefer it
over another method that doesn't suffer from the problem and has been used
for years?
My decisions are based upon an ideology without a doubt. That ideology is
one that I have developed over the course of 30 years of software
development. It is not based upon the language I used or the length of a
command. When Clipper (a dBASE-language) introduced the radically changed
5.0 version I suggested that people make the switch because as radical as
it was it solved many of the nagging problems introduced by the dBASE
language. One's software would be safer, more robust, probably tighter and
far less ambiguous. On the other hand it would tend to less-well
understood by dBASE developers but better understood by Pascal and C
developers and of course by any Clipper developer who could see how much
of an improvement the new version was.

Without a rational ideology it's only about defending one's turf. I'll
suggest that is why the VB6 diehards feel threatened by everything and
anything that isn't VB6.

That's another discussion, and I don't want to warm up the whole topic of
the migration problem again.
Does the shop you work in use VB.Net exclusively? Is anything there
written in C#?

I am currently working in another domain, not using .NET at all, but I would
not have a problem to do my work in C# if this was decided for a project.
 
H

Herfried K. Wagner [MVP]

Göran,

Göran Andersson said:
Can you give one single example where it would throw an exception?

Here is a real-world sample:

\\\
Public Module Program
Public Sub Main()
Dim f As New Foo()
f.Test = Nothing
End Sub
End Module

Public Class Foo
Private m_Test As String

Public Property Test() As String
Get
Return m_Test
End Get
Set(ByVal Value As String)
If String.IsNullOrEmpty(Value) Then
Throw _
New ArgumentNullException( _
"The 'Value' must not be 'Nothing' or an empty
string." _
)
End If
m_Test = Value
End Set
End Property
End Class
///
 
T

Tom Leylan

Herfried K. Wagner said:
This is not a discussion about basing preferences on ideology. I have
given technical reasons why I avoid using 'String.IsNullOrEmpty'
currently.

Yes and in this case you pointed out a bug. But how many other very similar
discussions have we had about the VB compatibility library?
Again, completely wrong. Although I am currently only active in the
English VB group, I use VB.NET, VB6, C#, and some other programming
languages equally. When using VB.NET, I use VB.NET, not only the .NET
Framework, as I do with other programming languages.

Completely wrong? It doesn't seem like that to me based upon your postings
covering some 5+ years. We've discussed topics in the VB6 newsgroup and now
in the VB.Net newsgroups but I don't recall reading or responding to any of
your posts on a C# newsgroup. Be that as it may I'm not stating that you
don't know another language I wrote quite plainly if you run into VB6 stuff
which is available in VB.Net you tend to choose the VB-compatible option.
Again I do not see the relation to the topic because nobody claims that
he/she "speaks" VB only.

The topic is not the Len() function, it is simply the example that sparked
the thread. The reality is there are people reading these messages that are
just learning VB and those that can write code in another but are pretty
unlikely to write an entire application in say Java. I often address
message to those groups to get them to consider that other languages
implement constructs which can be of use the VB.Net developer. That if (for
instance) there was no linked list that one couldn't be written.
Tom, in contrast to you I do not blame you for making mistakes. Everybody
makes them, I make them and even you make them.

I have never written "Well, then I suggest you specify more clearly what you
are talking about." to you or anybody else that I'm aware of with the
exception of my quoting you this time. Now you're contrasting me to the
person who wonders how I write software and suggests that I might learn to
write more clearly so they get their made up attributions correct.
I wrote:

| Trying to avoid the use of VB's intrinsic functions is like trying to
use a
| screwdriver to screw in a nail although there is a hammer in the toolbox
for
| the reason that "a screwdriver is a more professional tool than a
hammer."

Yes that's what you wrote. The .Net Framework is not "more professional"
any more than the Windows API is more professional. And you clearly wrote
"using a screwdriver to screw in a nail." So people who do it are in
essence "stupid" or are you now claiming that using a screwdriver to screw
in a nail is sometimes a reasonable solution? You aren't of course because
it isn't. If using the wrong tool is the same as using a "different" tool
it's time to go back to Logic 101.

Professionals often discuss various ways to solve a problem if somebody
posts "Yeah, or we could all just plink away on Amigas or something" (1) it
is an indication of their insincerity or lack of knowledge on the subject.

(1) from "Things to Say When You're Losing a Technical Argument"
It seems that you negatively connotate the term "low-level", which is not
what I do.

Calling functions in function library has never been considered low-level to
anyone I've known in the computer industry. But if you will agree we can
settle on Wikipedia's definition:
http://en.wikipedia.org/wiki/Low-level_programming_language. How does
String.IsNullOrEmpty (or other Framework methods) fall into the context as
expressed there? Are they close to the hardware and do they provide little
or no abstraction from a computer's microprocessor? The answer as you will
find through a little diligence is no, of course not.

And here is a definition from Answers.com that seems even further from what
you claim low-level means.
http://www.answers.com/topic/low-level-language

Rather than my applying a negative connotation doesn't it appear more likely
that you misused the term "low-level" to make people think it was harder to
use the .Net Framework?
Does that really matter here? If there are problems associated with the
function, regardless of their actual reason, why would I want to prefer it
over another method that doesn't suffer from the problem and has been used
for years?

It only matters when you insist that your misapplication of the screwdriver
analogy along with your misuse of the term low-level combined with your
insistence that there are fewer letters to type in the function name Len()
matters. You can write "I hit that bug" if you in fact hit that bug and
everybody would consider that a heads-up warning. Alternatively you can
scour your friend's blogs for rarely encountered bugs to support your
position. One is real, one is artificial. If I post a bug report there is
every reason to believe another developer writing reasonable code would
encounter it as well. If I write "VB.Net sucks" because I encounter a bug
I'd appreciate it people just told me to keep my unsupportable opinions to
myself.
I am currently working in another domain, not using .NET at all, but I
would not have a problem to do my work in C# if this was decided for a
project.

In that case what would you do if you needed need to test if a string was
IsNullOrEmpty? There is a bug in the JIT optimizer you know?
 
H

Herfried K. Wagner [MVP]

Tom --

Tom Leylan said:
Yes and in this case you pointed out a bug. But how many other very
similar discussions have we had about the VB compatibility library?

I do not specifically remember any discussions, but I believe that
"Microsoft.VisualBasic.dll" is a good (stable, handy, ...) library. On the
other hand, I'd not use the compatibility libraries.
Completely wrong? It doesn't seem like that to me based upon your
postings covering some 5+ years. We've discussed topics in the VB6
newsgroup and now in the VB.Net newsgroups but I don't recall reading or
responding to any of your posts on a C# newsgroup.

I have never been "active" in an English-speaking VB6 newsgroup (except in
X-posts). Being a native German speaker I am mostly active in the German
..NET (VB.NET, C#, .NET, VS) and VB6 groups. Maybe you are mixing me up with
someone else?
wrote quite plainly if you run into VB6 stuff which is available in VB.Net
you tend to choose the VB-compatible option.

If this is the opposite to "using the .NET Framework only and trying to
avoid using the VB Runtime Library", then that's true.
Calling functions in function library has never been considered low-level
to anyone I've known in the computer industry.

That's not what I consider low-level too. However, the link you posted

is about programming languages. I am talking about libraries and I conform
with the definition given in <URL:http://en.wikipedia.org/wiki/Low-level>.
A "wrapper" /can/ be more high-level than the functionality it wraps, but
this is /not necessarily/ the case.
Rather than my applying a negative connotation doesn't it appear more
likely that you misused the term "low-level" to make people think it was
harder to use the .Net Framework?

No, I didn't. I just wanted to say that parts of the .NET Framework provide
full functionality, but in reality a simplified form is commonly requested
and thus a wrapper can be more "high-level".
It only matters when you insist that your misapplication of the
screwdriver analogy along with your misuse of the term low-level combined
with your insistence that there are fewer letters to type in the function
name Len() matters. You can write "I hit that bug" if you in fact hit
that bug and everybody would consider that a heads-up warning.
Alternatively you can scour your friend's blogs for rarely encountered
bugs to support your position. One is real, one is artificial.

Take a look at my reply to Göran showing a typical scenario in which the
problem occurs ( said:
In that case what would you do if you needed need to test if a string was
IsNullOrEmpty? There is a bug in the JIT optimizer you know?

I'd use something not affected by the bug. My tests showed that it does not
occur when using 'Len' instead of 'IsNullOrEmpty' and that Len' provides a
semantically similar replacement. In C# I'd continue to write 'if (s ==
null || s.Length == 0)'.
 
S

Stephany Young

Tut, tut ... I'm surprised at you Herfried.

That is a spurious example, and, quite frankly, an insult to our
intelligence.

The call to String.IsNullOrEmpty is NOT throwing any exception.

The exception is being thrown by the Set accessor of property Foo.Test when
the result of the call to String.IsNullOrEmpty is True.
 
H

Herfried K. Wagner [MVP]

Stephany,

Stephany Young said:
Tut, tut ... I'm surprised at you Herfried.

That is a spurious example, and, quite frankly, an insult to our
intelligence.

The call to String.IsNullOrEmpty is NOT throwing any exception.

The exception is being thrown by the Set accessor of property Foo.Test
when the result of the call to String.IsNullOrEmpty is True.

You are right, I should really take more sleep. My bad and my excuses
(especially to Göran and Tom!). I have played around a little bit and I
could not come up with a useful example (which does not mean that such
examples do not exist). The problem seems to occur if the value of the
variable that is checked does not change and a loop is involved.
 
T

Tom Leylan

Herfried K. Wagner said:
I have never been "active" in an English-speaking VB6 newsgroup (except in
X-posts). Being a native German speaker I am mostly active in the German
.NET (VB.NET, C#, .NET, VS) and VB6 groups. Maybe you are mixing me up
with someone else?

No I was mistaken about the group. A quick scan of the archives located the
arguments between you and Fergus Cooney in 2003. I also believed it was
longer ago so perhaps it wasn't 5+ years after all.
That's not what I consider low-level too. However, the link you posted
is about programming languages.

Which last time I checked VB.Net is...
I am talking about libraries and I conform with the definition given in
<URL:http://en.wikipedia.org/wiki/Low-level>. A "wrapper" /can/ be more
high-level than the functionality it wraps, but this is /not necessarily/
the case.

So you're opting for the page that has the following examples:

<begin quote>
Climate is a high level description of the actions of the atmosphere and
oceans. Physics of water and gas molecules is a low level description of the
same system.

The instruction "write a creative poem on love" is a high level instruction.
The instruction "tighten the tendons in the right wrist to grip the pen" is
a low level description of an activity within that.

"Wikipedia is an encyclopedia" is a high level description compared to
"Wikipedia is a collection of textual articles on many topics". The former
reflects a higher level view of organization, purpose, concept and
structure, but does not explain what Wikipedia physically is. The latter is
more detailed as to what exactly Wikipedia contains and how it's made up,
but doesn't explain what its overall purpose and goals are. These are
typical features of high and low level descriptions.

<end quote>

As a guy named Herfried once wrote: "What's the relation to the topic?"
No, I didn't. I just wanted to say that parts of the .NET Framework
provide full functionality, but in reality a simplified form is commonly
requested and thus a wrapper can be more "high-level".

I'll ask the rest of the reading public.... is Class.Method() syntax
considered lower-level than Len( parameter ) syntax? And secondly is
avoiding the supposed lower-level syntax the goal? Would the VB.Net
developer like to see wrappers for more of the .Net library to help hide the
gory details of the classes?
Take a look at my reply to Göran showing a typical scenario in which the
problem occurs ( <URL:news:[email protected]>).

Well let's let that example die a peaceful death... :)
I'd use something not affected by the bug. My tests showed that it does
not occur when using 'Len' instead of 'IsNullOrEmpty' and that Len'
provides a semantically similar replacement. In C# I'd continue to write
'if (s == null || s.Length == 0)'.

If I thought I'd be affected by what seems to be an odd bug I'd tend to
write a function named StringIsNullOrEmpty() which performed the necessary
checks returning a boolean value. That way (when the patch was finally
made) I would only have to globally search for my function and replace it
with a dot in the name. Similarly I could scan any existing code and
replace any I found with a dot in them to my replacement function.

I would rather instruct a programming team to use my replacement function
rather than a sequence of instructions they could conceivably type in
incorrectly (or just differently) somewhere.
 
C

Cor Ligthert [MVP]

Playa.

Now you have all the answers for an empty string, here the answer for a
blank string.

If myString.Indexoff(" ") <> -1 then
'There are other characters than blanks in my string.
End if

If you mean an assigned string with no characters in it, than as made as
agreed answer from this newsgroup (after long investigations) by the long
time regulars in this newsgroup, we prefer:

If myString = ""

Try to avoid the = nothing, (or wrapped methods from that, because those
give back as well non assigned strings (for what the command to find only
those is myString Is Nothing).

Cor
 
C

Cor Ligthert [MVP]

Stephany,

I find your reaction overdone, there is in my opinion not any need to attack
Herfried personal on a code error. Just telling is for a guy as Herfried (or
me) more than enough to feel unhappy.

Cor


Stephany Young said:
Tut, tut ... I'm surprised at you Herfried.

That is a spurious example, and, quite frankly, an insult to our
intelligence.

The call to String.IsNullOrEmpty is NOT throwing any exception.

The exception is being thrown by the Set accessor of property Foo.Test
when the result of the call to String.IsNullOrEmpty is True.
 
C

Cor Ligthert [MVP]

Herfried,

In my opinion absolute no need for an excuse. If you would not have done it,
I would have done it.

There are better methods than using legacy "C" code which I see so often
showed by C# guys, which is in my eyes as well very inefficient.

Cor
 
C

Cor Ligthert [MVP]

Goran,

You are consequently using legacy by the time standarized C code in this
newsgroup and tell than that it is Net.

It is in the namespace Net. That does not mean that solely that is Net code.
Every part of code in the different frameworks is Net. Including the ones in
the Visual Basic Namespaces and the other newer ones comming.

In my opinion there is better code, not the legacy C as well not the legacy
VBclassics, altough I will never tell anybody not to use it, there can be
endless reasons for that.

Cor
 
T

Tom Leylan

Playa:

I'd be suspicious of the answers you receive from people who repeatedly post
code they have never bothered to test. A few folks do this on a regular
basis, their code never works I believe "they just couldn't bother" pretty
much sums up the attitude.

Dim s1 As String = " "

Debug.WriteLine("this tests a blank string")

If s1.IndexOf(" ") <> -1 Then
Debug.WriteLine("There are other characters than blanks in my
string")
End If

And the long-time regular developers typically prefer language-agnostic .Net
Framework syntax. Surely there should be a functional equivalent of the
IndexOf() method if function calls are the solution of the future. Perhaps
one will be added in the next version of VB?

My advice is never listen to somebody who can't post 3 lines of VB code that
actually does what they claim.
 
T

Tom Leylan

Cor Ligthert said:
Herfried,

In my opinion absolute no need for an excuse. If you would not have done
it, I would have done it.

No doubt you would have posted it precisely because it didn't demonstrate
the bug. Herfried noticed his error immediately and basically said "oops" I
think it is reasonable to assume you are too busy being offended that you
don't see it yet.
There are better methods than using legacy "C" code which I see so often
showed by C# guys, which is in my eyes as well very inefficient.

Cor

If you cut back on typing nonsense you might consider if the .Net String
class methods are legacy C code (which comes as a surprise to everybody)
that you just posted a non-working example using the .IndexOf() method.
It's VB.Net syntax only if you post it then?

Oh, I apologize also. In my other reply I wrote you probably didn't test
your 3 lines of code but I could be wrong.... it worked on your computer
right? Tell you what though if you stop calling people you don't know "C#
guys" I'll avoid calling you a VB hooligan.

As for inefficient... I think it's a safe bet you never tested your theory.
 
C

Cor Ligthert [MVP]

Hi all,

For those who don't understand, as me in the beginning. the long message
from Tom Leylan.

It is based on the fact that I wrote

"Indexoff" instead of "indexof".

I think that it is obviously that I wrote my sample direct in the message
and also obviously that with that there will be typos. I don't even apology
for that, it will happen more. About what Tom wrote, this are already to
many words for that.

Cor
 
T

Tom Leylan

Cor Ligthert said:
Hi all,

For those who don't understand, as me in the beginning. the long message
from Tom Leylan.

It is based on the fact that I wrote

"Indexoff" instead of "indexof".

I think that it is obviously that I wrote my sample direct in the message
and also obviously that with that there will be typos. I don't even
apology for that, it will happen more. About what Tom wrote, this are
already to many words for that.

There isn't an IndexOff method is there, so you meant IndexOf() right? And
your code doesn't work right? I want the original poster to realize that
when you wrote "here is the answer for a blank string" that it wouldn't
work.

If I posted code that didn't work what would you post? And when somebody
else suggests that VB developers would use the following syntax perhaps you
will think twice about calling it C legacy code or the person who posts it a
C# fanatic.

Debug.WriteLine("this tests a blank string")

If (s1.Trim().Length() <> 0) Then
Debug.WriteLine("There are other characters than blanks in my
string")
Else
Debug.WriteLine("There are no other characters than blanks in my
string")
End If

Cor learn something from the exchanges of the last week or so. The
newsgroup doesn't need a sheriff and you would likely not get the job. If
you like the person they can do no wrong if you don't they can do nothing
right.
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Cor said:
Goran,

You are consequently using legacy by the time standarized C code in this
newsgroup and tell than that it is Net.

By that reasoning it's not even C code, and most C code isn't C code at
all. C was not the first programming language.

Also by that reasoning, the LEN function is not a VB function at all,
it's a BASIC function.

Do you wish to continue down that path of that reasoning?
It is in the namespace Net. That does not mean that solely that is Net code.

Of course it is. Would it not be .NET code becase there are other
languages that uses similar syntax?
Every part of code in the different frameworks is Net. Including the ones in
the Visual Basic Namespaces and the other newer ones comming.

Yes, the VB6-style functions in the Microsoft.VisualBasic library is
also .NET. They are not, however, part of the System namespace.

Can you stop arguing about single words, and perhaps focus on the issue?
In my opinion there is better code, not the legacy C as well not the legacy
VBclassics, altough I will never tell anybody not to use it, there can be
endless reasons for that.

What code? What are you talking about?
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Cor said:
Playa.

Now you have all the answers for an empty string, here the answer for a
blank string.

Not at all. A blank string is the same as an empty string.
If myString.Indexoff(" ") <> -1 then
'There are other characters than blanks in my string.
End if

Again, you are posting nonsense code.

The condition tests if there is a space character in the string, but the
comment inside the If statement claims that it tests if there are other
characters than spaces in the string.

Whether the string contains a space character or not doesn't say
anything about what other characters the string may contain.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top