locked
Download Location On Form from FTP RRS feed

  • Question

  • hi, i am working on a game that i have made in vb.net, i was able to create an Uploader where when the character moves it is uploaded to a Server, now i am trying to add the multiplayer where other player movements are downloaded, i have started off with this code: 

     Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick

    dim client as new net.webclient       

    Label1.Location.X = client.DownloadString("ftp://User:Pass@Host/" + "Player_1_X_location" + ".txt")

            Label1.Location.Y = client.DownloadString("ftp://User:Pass@Host/" + "Player_1_Y_location" + ".txt")


    i Receive the Error: 

    Expression is a Value and therefore and cannot be the target of an assignment.

    is there any fixes for this? Thanks


    Sunday, February 26, 2012 6:17 PM

Answers

    • Edited by no1me Tuesday, February 28, 2012 1:10 PM
    • Marked as answer by Youen Zen Thursday, March 8, 2012 3:33 AM
    Sunday, February 26, 2012 6:27 PM
  • You are trying to convert a string explicitly to a location integral value, For the download string method I wouldn't use the + operands in there either, as those string values seem to remain constant anyways. Also this may be slow, so multithreading or DownloadStringAsync() may want to be used in your case, or both.

    Either way I would do this if I were you:

    Dim client As New System.Net.WebClient
            Me.Location = New Point(CType(client.DownloadString("ftp://User:Pass@Host/Player_1_X_location.txt"), Integer), _
                                    CType(client.DownloadString("ftp://User:Pass@Host/Player_1_Y_location.txt"), Integer))

    I am going to ASSUME, that you ONLY have number values in the Player_1_Y and X location.txt files however, otherwise this won't work.

    Cheers :)


    If a post helps you in any way or solves your particular issue, please remember to use the Propose As Answer option or Vote As Helpful
    ~ "The universe is an intelligence test." - Timothy Leary ~


    • Edited by Troy Garner Sunday, February 26, 2012 6:35 PM
    • Marked as answer by Youen Zen Thursday, March 8, 2012 3:33 AM
    Sunday, February 26, 2012 6:33 PM

All replies

    • Edited by no1me Tuesday, February 28, 2012 1:10 PM
    • Marked as answer by Youen Zen Thursday, March 8, 2012 3:33 AM
    Sunday, February 26, 2012 6:27 PM
  • so taking it as i  need to turn this script: 

    Dim exitLocation as New System.Drawing.Point(140, exitButton.Location.Y) exitButton.Location = exitLocation

    and turn it to

    textbox1.text = client.downloadstring = ("FTP://file/")

    Dim playerlocation as New System.Drawing.Point(textbox1.text, label1.Location.Y) label1.Location = playerlocation

    ?

    Sunday, February 26, 2012 6:33 PM
  • You are trying to convert a string explicitly to a location integral value, For the download string method I wouldn't use the + operands in there either, as those string values seem to remain constant anyways. Also this may be slow, so multithreading or DownloadStringAsync() may want to be used in your case, or both.

    Either way I would do this if I were you:

    Dim client As New System.Net.WebClient
            Me.Location = New Point(CType(client.DownloadString("ftp://User:Pass@Host/Player_1_X_location.txt"), Integer), _
                                    CType(client.DownloadString("ftp://User:Pass@Host/Player_1_Y_location.txt"), Integer))

    I am going to ASSUME, that you ONLY have number values in the Player_1_Y and X location.txt files however, otherwise this won't work.

    Cheers :)


    If a post helps you in any way or solves your particular issue, please remember to use the Propose As Answer option or Vote As Helpful
    ~ "The universe is an intelligence test." - Timothy Leary ~


    • Edited by Troy Garner Sunday, February 26, 2012 6:35 PM
    • Marked as answer by Youen Zen Thursday, March 8, 2012 3:33 AM
    Sunday, February 26, 2012 6:33 PM
  • Yep, Testing out the code now. ill reply on the status.
    Sunday, February 26, 2012 7:11 PM