Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have the below codes:

 

Dim pass As String = TextBox2.Text

'returndata is already a string

 

If trim(returndata) = "" Then

MsgBox("Wrong ID")

Else

MsgBox("Correct ID")

End If

 

But the messagebox always comes out with "Correct ID", even when the if statement is true.

 

Anyone here can help?

Posted
I have the below codes:

 

Dim pass As String = TextBox2.Text

'returndata is already a string

 

If trim(returndata) = "" Then

MsgBox("Wrong ID")

Else

MsgBox("Correct ID")

End If

It seems odd to me that you showed where the string pass comes from but then don't use it, and yet you don't show where the string returndata comes from which is whats supposedly causing your problem. I can see no reason this code would always show "Correct ID".

 

On a side note you should perhaps consider using String.Empty instead of "".

Anybody looking for a graduate programmer (Midlands, England)?
Posted
It seems odd to me that you showed where the string pass comes from but then don't use it, and yet you don't show where the string returndata comes from which is whats supposedly causing your problem. I can see no reason this code would always show "Correct ID".

 

On a side note you should perhaps consider using String.Empty instead of "".

 

hi there thanks for your reply,

 

At first i do not know where to start with......because it may become very lengthy and complicated.

 

hmmm...i guess maybe you are right.....it maybe difficult to understand if i just put those codes above...below is where the returndata came from.

 

Dim bytes(tcpClient.ReceiveBufferSize) As Byte

networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))

Dim returndata As String = Encoding.ASCII.GetString(bytes, 0, bytes.Length)

 

Thanks :)

Posted
If you step through the code in a debugger or print the contents of returndata to the debug window what values does it contain? Does it every contain an empty string?

 

hi,

 

I do not know how to get the debug to show me the ouput of the returndata?

 

I beginning to think that my returndata is not empty.

Because at my server my returndata has a <<enter>>

does this "enter" actually make it look like not a string.empty?

 

While myReader.Read

textbox1.text += myReader("") & vbCrLf

End While

 

textbox1.text = returndata

Posted

it really looks dumb...

i even tried creating another textbox

textbox3.text = ""

textbox3.text += vbCrLf

and compare textbox1 and textbox3.......still keep on correct Id when it is suppose to be wrong id.........

Posted
To get the debugger to display information you need to set a breakpoint. Todo this click in the gray bar to the left hand side of the code level with a line that contains the variable returndata, then when the application reaches that line it will stop and if you point at the variable it will tell you its value. Alternatively if you didn't understand that output a Messagebox with returndata just before the If statement and see what it contains.
Anybody looking for a graduate programmer (Midlands, England)?
  • Administrators
Posted

If your string contains a CRLF then it isn't an empty string.

 

If you want to display debug information then Debug.WriteLine(...) will do that for you.

 

Also as a personal preference you might want to look at using some of the .Net equivalents to the legacy VB routines i.e.


Dim pass As String = TextBox2.Text
'returndata is already a string

If returndata.Trim() = String.Empty Then
MessageBox.Show("Wrong ID")
Else
MessageBox.Show("Correct ID")
End If

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted
If your string contains a CRLF then it isn't an empty string.

 

If you want to display debug information then Debug.WriteLine(...) will do that for you.

 

Also as a personal preference you might want to look at using some of the .Net equivalents to the legacy VB routines i.e.


Dim pass As String = TextBox2.Text
'returndata is already a string

If returndata.Trim() = String.Empty Then
MessageBox.Show("Wrong ID")
Else
MessageBox.Show("Correct ID")
End If

 

hmm...you mean just code: Debug.WriteLine()? Where should i place it?

 

ok...if my returndata has a VBCRLF....how should i compare it?

:confused:

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...