Re: How is this conditional able to execute?

Tech-Archive recommends: Fix windows errors by optimizing your registry



I only put the values that way to show what they are. I wasn't actually
assigning anything.

This code is in a loop. Most of the time, returndata is the empty string.

networkStream = tcpClient.GetStream()
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes, 0,
tcpClient.ReceiveBufferSize)
Dim returndata As String =
Trim(Encoding.UTF8.GetString(bytes))

If returndata.ToString <> "" And returndata.ToString
<> ClientForm.ReturnData Then
ClientForm.ReturnData = returndata
returndata = Nothing
Else
End If
End If

bytes always has a length of 8193. Up until about the 35th element of its
array, the values are non zero. After that they are all zero. Possibly I'm
not seeing something that is kept in bytes when I assign it to returndata?
Although returndata appears to be the empty string, it may have some other
value.



"Stephany Young" <noone@localhost> wrote in message
news:e6sPJevQFHA.576@xxxxxxxxxxxxxxxxxxxxxxx
> Did you forget to include the values?
>
> Your code cannot possiblity work because
>
> returndata.ToString = ""
>
> gives a compile-time error:
>
> error BC30068: Expression is a value and therefore cannot be the target
> of an assignment.
>
> It would pay to show the ACTUAL code including the declarations of and
> assignments to variables returndata and ClientForm.ReturnData.
>
>
> "Brett" <no@xxxxxxxx> wrote in message
> news:%23HIUlxuQFHA.1476@xxxxxxxxxxxxxxxxxxxxxxx
>> The following conditional executes given the values listed. I've listed
>> the values below for each of these variables. How is it that the
>> conditional still executes:
>>
>> If (returndata.ToString <> "") And (returndata.ToString <>
>> ClientForm.ReturnData) Then
>>
>> returndata.ToString = ""
>> ClientForm.ReturnData = Nothing
>>
>> The first test fails and the second passes. The AND should then fail
>> correct?
>>
>> Thanks,
>> Brett
>>
>
>


.



Relevant Pages

  • Re: How is this conditional able to execute?
    ... Are you saying that directly after execution of the line: ... Dim returndata As String = Trim) ... >assigning anything. ... returndata is the empty string. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: How is this conditional able to execute?
    ... Public Shared ReturnData As String ... It is always assigned a string value. ... >>assigning anything. ... >>> It would pay to show the ACTUAL code including the declarations of and ...
    (microsoft.public.dotnet.languages.vb)