views:

360

answers:

1

Hey guys,

I imported the Winsock feature in my vb.net application, so I can make a Chat System. I just have one little problem with my program. In the GetData method of my program,

CLIENT SIDE:

*Dim strData As String*

    AxWinsock1.GetData(strData, vbString)
    TextBox1.Text = TextBox1.Text & _
    strData & vbCrLf

It will underline the whole first line, unless have an maxLen as Object in. So I plugged in Nothing, since I thought it was optional. Now when I debug, and I send a message from the server, it won't display anything. I put in vbByte as the maxLen object, and now it only shows part of the message. Can anyone tell me how to fix this. This works in VB6...

PS: I am not going to use the System.Namespaces function of VB.NET since, I find the Winsock feature much easier.

Thanks

A: 

vbByte is a constant with a value of 17, so you actually send a max length of 17 ;-)

You will want to send a bigger number as the max length. If what you want to send as a max length is the upper bound of the Byte data type you could send Byte.MaxValue (which is 255).

Edit:

I don't know what is the upper bound, but you can try Integer.MaxValue, or some arbitrary big value like 1000000...

Looking at the documentation, I noticed two things:

  1. maxLen should be optional, I don't know why it would flag an error when you don't specify it, what kind of error is it?

  2. It's mentioned that it's common to use GetData with a DataArrival event, is that your case? If it is, you could pass the totalBytes argument as the maxLen.

Meta-Knight
What if I want something larger than that?
Kevin
ALso, I can do byte.maxvalue as the maxlen as object for some reason. I can do byte.long, but that will seperate my sentence when sending it to the client.
Kevin
I answered your question in my edit, but I have no idea what is byte.long??
Meta-Knight
Yay, it works, I used the integer.maxvalue. Thanks@!
Kevin