Please help me look at my code? Why receiving data will be more and more slow, I am the first to send a command to my server, the server will then return some warning information, with tens of thousands of lines of information about, Receive the HTML code is as follows:
Private Sub Winsock_DataArrival (ByVal bytesTotal As Long)
The Static strData, strSend As Byte
Winsock. GetData strData, vbString
RichTextBox1. Text=RichTextBox1. Text & amp; StrData
RichTextBox1. SelStart=Len (RichTextBox1. Text)
End Sub
CodePudding user response:
Private Sub Winsock_DataArrival (ByVal bytesTotal As Long) Dim strData () As Byte Dim f As Integer ReDim strData (bytesTotal - 1) Winsock. GetData strData, vbByte F=FreeFile () Open "data" for append as # f Print # f, StrConv (strData, vbUnicode) Close # f 'RichTextBox1. Text=RichTextBox1. Text & amp; StrConv (strData, vbUnicode) 'RichTextBox1. SelStart=Len (RichTextBox1. Text)
End Sub
CodePudding user response:
Winsock. GetData strData, vbArray + vbByte
CodePudding user response:
Thank you very much, but if I find my way, also can write directly into the TXT file, is there any way can show receive files, but does not affect the speed?
CodePudding user response:
Don't use RichTextBox1, use the listview control
CodePudding user response:
RichTextBox1 refresh is time-consuming
CodePudding user response:
Private Sub Winsock_DataArrival (ByVal bytesTotal As Long) Dim strData () as byte ReDim strData (bytesTotal - 1) Winsock. GetData strData, vbbyte RichTextBox1. Text=RichTextBox1. Text & amp; Strconv (strData, vbUnicode) RichTextBox1. SelStart=Len (RichTextBox1. Text) Erase strData End Sub
Try, slow estimates is should be static variables declared with the static's wrong with you
CodePudding user response:
I think, "are getting slower and slower," the key reason, or is it 1: RichTextBox1. Text=RichTextBox1. Text & amp; StrData
When the content of the "text" a lot of that "string operation" behind time-consuming increases (secondary factors), to "object assignment" also consumes a lot of time, And operation of the building Lord "frequent refresh content", will appear more and more slow,
Maybe use qinguangjun123 said method, on the 4th floor can be improved,
CodePudding user response:
It will be better and slow ah, you need to see all the received data? Don't need, truncation, show only the latest article n is ok,