Results 1 to 25 of 25

Thread: Sending Large String Data

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Posts
    246

    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?

  2. #2
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959

    Re: Sending Large String Data

    VB Code:
    1. Private Sub Command1_Click()
    2.  
    3. Dim sbuff As String
    4. Dim i     As Integer
    5.  
    6.     For i = 1 To Len(Text1.Text) Step 200
    7.         sbuff = Mid(Text1.Text, i, 200)
    8.         Winsock1.SendData sbuff
    9.         DoEvents
    10.         'sleep 100
    11.     Next i
    12.    
    13.  
    14. End Sub

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Posts
    246

    Re: Sending Large String Data

    Thanks man!

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Posts
    246

    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:
    1. Public Sub TxtLog()
    2. frmMain.Text4 = frmTxtLog.Text1
    3. Dim sbuff As String
    4. Dim i As Integer
    5.  
    6. For i = 1 To Len(frmMain.Text4.Text) Step 200
    7. sbuff = Mid(frmMain.Text4.Text, i, 200)
    8. frmMain.Winsock1.SendData "txtlog" & sbuff
    9. DoEvents
    10. Next i
    11. end sub

    Client -

    VB Code:
    1. Private Sub Winsock1_DataArrival(Index As Integer, ByVal bytesTotal As Long)
    2.     Winsock1(Index).GetData data
    3.     If Left$(data, 6) = "txtlog" Then TxtLog1
    4.     End Sub
    5.  
    6. Public Sub TxtLog1()
    7. If frmTxtLog.Text1 = "" Then
    8. frmTxtLog.Text1 = Mid(data, 7, Len(data))
    9. Else
    10. frmTxtLog.Text1 = frmTxtLog.Text1 & vbNewLine & Mid(data, 7, Len(data))
    11. End If
    12. End Sub

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Posts
    246

    Re: Sending Large String Data

    please help me

  6. #6
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959

    Re: Sending Large String Data

    not with you.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Posts
    246

    Re: Sending Large String Data

    Whats wrong with me?

  8. #8
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959

    Re: Sending Large String Data

    i mean i dont get your problem.

  9. #9
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    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

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Posts
    246

    Re: Sending Large String Data

    Quote 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?

  11. #11
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Sending Large String Data

    Each call to txtLog gets passed a line of data with the txtlog.

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Posts
    246

    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?

  13. #13
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Sending Large String Data

    That isnt working for me
    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.

  14. #14

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Posts
    246

    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.

  15. #15

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Posts
    246

    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?

  16. #16
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    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

  17. #17

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Posts
    246

    Re: Sending Large String Data

    Will this work if the data is varying? Cuz obviously more is going to be added to the log.

  18. #18
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    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.

  19. #19

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Posts
    246

    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)

  20. #20
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Sending Large String Data

    show me a string that does not work in the method I showed you and I'll fix it.

  21. #21

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Posts
    246

    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

  22. #22
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    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.

  23. #23

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Posts
    246

    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?

  24. #24
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    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?

  25. #25

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Posts
    246

    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
  •  



Click Here to Expand Forum to Full Width