placing a value in a string

Attempting to place a value in a string, value comes out wrong

Page 1 of 1

4 Replies - 1879 Views - Last Post: 02 September 2009 - 02:24 PM Rate Topic: -----

#1 stickiler  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 01-September 09

placing a value in a string

Posted 01 September 2009 - 04:47 AM

Ok i am writing a program, and this is only a very small part of it, but it is crucial. i am trying to upload a file to my server, and i am placing the full filepath of the server in a string, before uploading the file. here is what i have:
					Dim temp2 As String = "http://" & hsip & ":32376" & File.Replace("C:", "")
					MsgBox(temp2)


that is just the section that places the value into the string variable, then display the variable, for debugging purposes. now this doesnt place the right value in the variable, it only adds the "http://" & hsip part, then ignores the rest.

any ideas what could be wrong?

thanks for any and all help :)

Is This A Good Question/Topic? 0
  • +

Replies To: placing a value in a string

#2 mark.bottomley  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 176
  • View blog
  • Posts: 990
  • Joined: 22-April 09

Re: placing a value in a string

Posted 01 September 2009 - 05:36 AM

check the contents of hsip for any extra characters or carriage returns/linefeeds. Also check the value of File before the replace command. Specifically, output each of the component strings with Debug.Print and/or check them in the debugger prior to the concatenation.
Was This Post Helpful? 0
  • +
  • -

#3 stickiler  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 01-September 09

Re: placing a value in a string

Posted 02 September 2009 - 12:56 AM

View Postmark.bottomley, on 1 Sep, 2009 - 04:36 AM, said:

check the contents of hsip for any extra characters or carriage returns/linefeeds. Also check the value of File before the replace command. Specifically, output each of the component strings with Debug.Print and/or check them in the debugger prior to the concatenation.


ok i think i found the problem, i am recieving data through a stream, then converting the bytes that i received into a string, using Encoding.ASCII.GetString(), but the byte array is size 8096, but the data in the array is only 14 bytes long, so when it gets converted into a string, a lot of values of "Nothing" get added to the end, which only appear when you then convert that string into a char array, although i have no idea how to remove those extra characters.
Was This Post Helpful? 0
  • +
  • -

#4 mark.bottomley  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 176
  • View blog
  • Posts: 990
  • Joined: 22-April 09

Re: placing a value in a string

Posted 02 September 2009 - 05:38 AM

String.Trim can remove extra characters once you know what they are - or you can copy the characters over to another sting until you find a character you don't want (or up til a character you know is the last character) - Show us the code...
Was This Post Helpful? 0
  • +
  • -

#5 stickiler  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 01-September 09

Re: placing a value in a string

Posted 02 September 2009 - 02:24 PM

View Postmark.bottomley, on 2 Sep, 2009 - 04:38 AM, said:

String.Trim can remove extra characters once you know what they are - or you can copy the characters over to another sting until you find a character you don't want (or up til a character you know is the last character) - Show us the code...

i've just posted the relevant code here

		stream.Read(buf, 0, tcpclient.ReceiveBufferSize)
		hsip = Encoding.ASCII.GetString(buf, 0, 15)
					hsip = hsip.Replace(ControlChars.Cr, "").Replace(ControlChars.Lf, "")
					Dim test1(hsip.Length) As Char
					test1 = hsip.ToCharArray


the reason i am placing the hsip into a char array, is because i was checking for those extra characters, which dont show up in the string.

any help is appreciated
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1