If (astrThisOne <> "") Then falls through even if astrThisOne <> ""

  • Thread starter Thread starter active
  • Start date Start date
A

active

I use quickwatch on
(astrThisOne <> "")
and it reports: False

as it should because
astrThisOne reports: ""

Yet
If (astrThisOne <> "") Then
executes the Then clause


I'm going to try checking the length instead but would like to know what's
happening because I've got many such checks

I've got the code at Break in front of me and know what I've said above is
true because I can easily check it.


Thanks
Cal

I've got the code at Break in front of me and know what I've said above is
true because I can easily check it.
Break highlighted" DoThisItemQ = True and the quickwatchs as described
above.


If (astrThisOne <> "") Then
If (sstrLastOne <> astrThisOne) Then DoThisItemQ = True
End If
 
active said:
I use quickwatch on
(astrThisOne <> "")
and it reports: False

as it should because
astrThisOne reports: ""

Yet
If (astrThisOne <> "") Then
executes the Then clause


I'm going to try checking the length instead but would like to know
what's happening because I've got many such checks

I've got the code at Break in front of me and know what I've said
above is true because I can easily check it.


Thanks
Cal

I've got the code at Break in front of me and know what I've said
above is true because I can easily check it.
Break highlighted" DoThisItemQ = True and the quickwatchs as
described above.


If (astrThisOne <> "") Then
If (sstrLastOne <> astrThisOne) Then DoThisItemQ = True
End If

That's only a drawback/bug of the IDE. The command seems to get executed but
it does not. BTW, can easily be checked after also watching DoThisItemQ. You
will see that it stays False (if it was False before).
 
* " active said:
I use quickwatch on
(astrThisOne <> "")
and it reports: False

as it should because
astrThisOne reports: ""

Yet
If (astrThisOne <> "") Then
executes the Then clause


I'm going to try checking the length instead but would like to know what's
happening because I've got many such checks

I've got the code at Break in front of me and know what I've said above is
true because I can easily check it.

That's a "known" bug in the IDE.
 
I do watch DoThisItemQ and it changes from False to True
which is why I investageted in the first place.

Thanks for leting me in on something that might be good to know in the
future but I don't think it solves my current problem.

I expected someone to say' you don't can't check for "" that way in VB.NET,
but I now assume it's OK.

I'm guessing that quickwatch showing astrThisOne as "" is the problem.

For one thing it's declared thus: astrThisOne As String

Quickwatch simply shows it as: astrThisOne with a value of: ""

If it is an object shouldn't quickwatch show all the members?

It get set by:
astrThisOne = Trim(CagListViews1.SelectedItem(alngColumn, alngItem))


which uses results in:

Get

Dim llvwX As ListViewItem

llvwX = lvwSelected.Items(alngIndex)

If alngColumn = 0 Then

SelectedItem = llvwX.Text

Else

SelectedItem = llvwX.SubItems(alngColumn - 1).Text

End If

End Get





I wonder what get returned fo a subitem that is never set?
I tried Debug.WriteLine(astrThisOne.ToString)
and nothing gets written when it's ""

Any ideas?

Thanks for the reply
Cal
 
I found something

It get set by:
astrThisOne = Trim(CagListViews1.SelectedItem(alngColumn, alngItem))

which goes to CagListViews1.SelectedItem as follows:

Get

Dim llvwX As ListViewItem

llvwX = lvwSelected.Items(alngIndex)

If alngColumn = 0 Then

SelectedItem = llvwX.Text

Else

SelectedItem = llvwX.SubItems(alngColumn - 1).Text

End If

End Get

I wonder what get returned fo a subitem that is never set?

I tried:

Dim arr() As Char
arr = astrThisOne.ToCharArray(3, 4)
Console.Write("The letters in '{0}' are: '", astrThisOne)
Console.Write(arr)
Console.WriteLine("'")
Console.WriteLine("Each letter in '{0}' is:", astrThisOne)
Dim c As Char
For Each c In arr
Console.WriteLine("/" & Asc(c) & "/")
Console.WriteLine("\" & AscW(c) & "\")
Next c

Produces 4 sets of :
\0\
/0/

Seems that listview returns 4 nulls. I'd quess "" is one null

So what to do? Generate a trim that also removes nulls?
Any other suggestions?
 
Bug below. Note the (3, 4) bug below.
Anyway, I get 30 pairs not 4. The original data came from a file with 30
characters for that item so I know where to look.

The problem is that the IDE shows the variable as "" when it actually
contains 30 nulls


Thanks
Cal
 
The problem is that the IDE shows the variable as "" when it actually
contains 30 nulls

That is the "known" bug. (One of them at least). If a string contains a
null, then in the IDE, it displays incorrectly.

Bad news is that it doesn't appear to be fixed in Whidbey, not yet anyway.
 
Back
Top