|
-
Feb 1st, 2006, 08:22 PM
#1
Thread Starter
Addicted Member
Sending Large String Data
Ok, Heres the story. I have all this string data stored in text1. How do I go about sending it over to the server in 200 character intervals using winsock?
-
Feb 1st, 2006, 08:53 PM
#2
Re: Sending Large String Data
VB Code:
Private Sub Command1_Click()
Dim sbuff As String
Dim i As Integer
For i = 1 To Len(Text1.Text) Step 200
sbuff = Mid(Text1.Text, i, 200)
Winsock1.SendData sbuff
DoEvents
'sleep 100
Next i
End Sub
-
Feb 1st, 2006, 09:20 PM
#3
Thread Starter
Addicted Member
Re: Sending Large String Data
-
Feb 1st, 2006, 09:46 PM
#4
Thread Starter
Addicted Member
Re: Sending Large String Data
Ok, Now I have another problem. Im using an identifier to tell it where to put the data and the identifier is "txtlog". My problem is that I cannot get "txtlog" to NOT show in frmTxtLog.Text1, so I see a bunch of random "txtlog" all over the place. How do I format it so that it does not show "txtlog"?
Thanks man!
Server -
VB Code:
Public Sub TxtLog()
frmMain.Text4 = frmTxtLog.Text1
Dim sbuff As String
Dim i As Integer
For i = 1 To Len(frmMain.Text4.Text) Step 200
sbuff = Mid(frmMain.Text4.Text, i, 200)
frmMain.Winsock1.SendData "txtlog" & sbuff
DoEvents
Next i
end sub
Client -
VB Code:
Private Sub Winsock1_DataArrival(Index As Integer, ByVal bytesTotal As Long)
Winsock1(Index).GetData data
If Left$(data, 6) = "txtlog" Then TxtLog1
End Sub
Public Sub TxtLog1()
If frmTxtLog.Text1 = "" Then
frmTxtLog.Text1 = Mid(data, 7, Len(data))
Else
frmTxtLog.Text1 = frmTxtLog.Text1 & vbNewLine & Mid(data, 7, Len(data))
End If
End Sub
-
Feb 1st, 2006, 11:15 PM
#5
Thread Starter
Addicted Member
Re: Sending Large String Data
-
Feb 2nd, 2006, 12:13 AM
#6
Re: Sending Large String Data
-
Feb 2nd, 2006, 12:19 AM
#7
Thread Starter
Addicted Member
Re: Sending Large String Data
-
Feb 2nd, 2006, 12:25 AM
#8
Re: Sending Large String Data
i mean i dont get your problem.
-
Feb 2nd, 2006, 01:45 AM
#9
Re: Sending Large String Data
You have to put the data back together on the receiver end. Something like this
Code:
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Static allData As String
Dim x As String
Dim Lines
Dim i As Integer
Winsock1.GetData x
'put back together
allData = allData & x
'Now you can look for your markers
ipos = InStr(allData, "txtlog")
If ipos > 0 Then
'strip off line
Lines = Split(allData, "txtlog")
For i = 0 To UBound(Lines) - 2
'do what you want with the line here
Call txtLog(Lines(i))
Next i
'save last one
allData = Lines(i)
End If
End Sub
-
Feb 2nd, 2006, 06:37 PM
#10
Thread Starter
Addicted Member
Re: Sending Large String Data
 Originally Posted by moeur
You have to put the data back together on the receiver end. Something like this
Code:
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Static allData As String
Dim x As String
Dim Lines
Dim i As Integer
Winsock1.GetData x
'put back together
allData = allData & x
'Now you can look for your markers
ipos = InStr(allData, "txtlog")
If ipos > 0 Then
'strip off line
Lines = Split(allData, "txtlog")
For i = 0 To UBound(Lines) - 2
'do what you want with the line here
Call txtLog(Lines(i))
Next i
'save last one
allData = Lines(i)
End If
End Sub
This will save all the data minus "txtlog" in the textbox?
-
Feb 2nd, 2006, 06:40 PM
#11
Re: Sending Large String Data
Each call to txtLog gets passed a line of data with the txtlog.
-
Feb 2nd, 2006, 06:55 PM
#12
Thread Starter
Addicted Member
Re: Sending Large String Data
That isnt working for me 
How do I say put everything but the first 6 characters in the data into txtlog?
-
Feb 2nd, 2006, 07:37 PM
#13
Re: Sending Large String Data
That isn't working for me 
Please provide more information, either explain what is and is not happening, or upload a demo project(s) that we can work with.
-
Feb 2nd, 2006, 07:52 PM
#14
Thread Starter
Addicted Member
Re: Sending Large String Data
Im trying to get the data and display it in the txtlog.text...but with every section i send...it puts the "txtlog" in front of the data I want to see. I dont want to see "txtlog" at the beginning of every chunk that it sends. Im thinking I can just tell it to put all the data..but the 6 first characters in the textbox.
-
Feb 2nd, 2006, 08:39 PM
#15
Thread Starter
Addicted Member
Re: Sending Large String Data
Ok, heres the thing...
winsock1.getdata data
If the first 6 letters of data = txtlog then TxtLog
Public Sub TxtLog
frmmain.txtlog.text = data
end sub
pretty much theres it in short w/o the correct stuff. My problem is that I run the program and grab the data and it shows like this
txtlogajkls dhfasjflka sjflksjflskajlfsatxtlog alkjdflasjflkjdjlfsa djkftxtlogalksdjfl askjftxtlogalksdjfalksjf txtloglas sldfkakdsjfsaklj aksldfjalsfjsakfjsakfj as fatxtlog lkajsdfasjf lasf txtlogalksdjfalsjfd
Notice how there are random "txtlog"'s all over the place because that is in the data that the server sends. So I need to do something like.
winsock1.getdata data
If the first 6 letters of data = txtlog then TxtLog
Public Sub TxtLog
frmmain.txtlog.text = data - the first 6 characters at the beginning
end sub
Is this better explained?
-
Feb 2nd, 2006, 09:01 PM
#16
Re: Sending Large String Data
OK, try this to see what I'm trying to do
Note: I've set the Multiline property of Text1 to True
Code:
Option Explicit
Private Sub Command1_Click()
Dim inData As String
Dim splitData() As String
Dim i As Integer
Text1 = ""
inData = "txtlogajkls dhfasjflka sjflksjflskajlfsatxtlog alkjdflasjflkjdjlfsa djkftxtlogalksdjfl askjftxtlogalksdjfalksjf txtloglas sldfkakdsjfsaklj aksldfjalsfjsakfjsakfj as fatxtlog lkajsdfasjf lasf txtlogalksdjfalsjfd"
splitData = Split(inData, "txtlog")
For i = 0 To UBound(splitData) - 1
If Len(Trim(splitData(i))) > 0 Then _
Text1 = Text1 & Trim(splitData(i) & vbCrLf)
Next i
End Sub
-
Feb 2nd, 2006, 09:32 PM
#17
Thread Starter
Addicted Member
Re: Sending Large String Data
Will this work if the data is varying? Cuz obviously more is going to be added to the log.
-
Feb 2nd, 2006, 09:38 PM
#18
Re: Sending Large String Data
this only depends on the fact that the strings are separated by your special marker, so if that doesn't vary then it will be fine.
Try it out and see is the best way to answer most of the questions you'll have.
-
Feb 2nd, 2006, 10:07 PM
#19
Thread Starter
Addicted Member
Re: Sending Large String Data
Yeah, I just tried it..and it only works if that is exactly what I put into the txtbox, but as the data is always going to change, it doesnt work.
Why wont this work?
frmTxtLog.Text1 = frmTxtLog.Text1 & vbNewLine & data
frmTxtLog.Text1 = Mid(frmTxtLog.Text1, 7, Len(frmTxtLog.Text1) - 6)
-
Feb 2nd, 2006, 10:18 PM
#20
Re: Sending Large String Data
show me a string that does not work in the method I showed you and I'll fix it.
-
Feb 2nd, 2006, 10:38 PM
#21
Thread Starter
Addicted Member
Re: Sending Large String Data
Its the fact that I want to compile it some time and I dont want to have to go and change everything everytime i get new data. Can I just do this with yours?
Option Explicit
Private Sub Command1_Click()
Dim inData As String
Dim splitData() As String
Dim i As Integer
Text1 = ""
inData = text1 <========= right here
splitData = Split(inData, "txtlog")
For i = 0 To UBound(splitData) - 1
If Len(Trim(splitData(i))) > 0 Then _
Text1 = Text1 & Trim(splitData(i) & vbCrLf)
Next i
End Sub
-
Feb 2nd, 2006, 10:45 PM
#22
Re: Sending Large String Data
Yes,
This is what I'm trying to tell you that this method works on all data as long as your marker is there to separate the data.
Show me some data where it is not working.
-
Feb 2nd, 2006, 11:00 PM
#23
Thread Starter
Addicted Member
Re: Sending Large String Data
Code:
Public Sub txtlog1()
Dim inData As String
Dim splitData() As String
Dim i As Integer
frmTxtLog.Text1 = data
inData = frmTxtLog.Text1
splitData = Split(inData, "txtlog")
For i = 0 To UBound(splitData) - 1
If Len(Trim(splitData(i))) > 0 Then _
frmTxtLog.Text1 = frmTxtLog.Text1 & Trim(splitData(i) & vbCrLf)
Next i
End Sub
What am I doing wrong?
-
Feb 2nd, 2006, 11:07 PM
#24
Re: Sending Large String Data
You'll have to show me how you are calling this routine.
what is data?
What input are you using and what output do you get that you don't like?
-
Feb 2nd, 2006, 11:39 PM
#25
Thread Starter
Addicted Member
Re: Sending Large String Data
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Winsock1.GetData data
If Left$(data, 6) = "txtlog" Then txtlog1
End Sub
Thats what data is.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|