Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 150,092 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,819 people online right now. Registration is fast and FREE... Join Now!




Strange problem with VB.NET Arrays Length

 
Reply to this topicStart new topic

Strange problem with VB.NET Arrays Length

pe_mitev
18 Apr, 2008 - 12:04 AM
Post #1

D.I.C Head
Group Icon

Joined: 28 Dec, 2007
Posts: 72


Dream Kudos: 50
My Contributions
Hello everybody, since yesterday I have been fighting with one problem that seems to me to be very elementary, but I cannot manage to solve it and understand where the error is in fact.

CODE

Dim temp = data.Split(";")
MsgBox(temp(1).Length) ' returns 4086??? Why? The string for instance is "Today is sunny;The morning was also sunny"

Dim a As String = "john"
MsgBox(a.Length) 'returns 4, as it must


In conclusion, I cannot understand where the error is and I am looking for your help!
Thank you in advance!
User is offlineProfile CardPM
+Quote Post

Jayman
RE: Strange Problem With VB.NET Arrays Length
18 Apr, 2008 - 07:34 AM
Post #2

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 7,319



Thanked: 66 times
Dream Kudos: 500
Expert In: Everything

My Contributions
Using VS2005, temp(1).Length returns 26, as expected.

Which version are you using?
User is offlineProfile CardPM
+Quote Post

pe_mitev
RE: Strange Problem With VB.NET Arrays Length
18 Apr, 2008 - 11:30 AM
Post #3

D.I.C Head
Group Icon

Joined: 28 Dec, 2007
Posts: 72


Dream Kudos: 50
My Contributions
2008, but I am getting the data from the server(TCP) via this code:
CODE

            'Accept the pending client connection and return
            'a TcpClient initialized for communication.
            Dim tcpClient As TcpClient = tcpListener.AcceptTcpClient()
            'MsgBox("Connection accepted.")
            ' Get the stream
            Dim networkStream As NetworkStream = tcpClient.GetStream()
            ' Read the stream into a byte array
            Dim bytes(tcpClient.ReceiveBufferSize) As Byte
            networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
            ' Return the data received from the client to the console.
            Dim clientdata As String = Encoding.Unicode.GetString(bytes)


User is offlineProfile CardPM
+Quote Post

pe_mitev
RE: Strange Problem With VB.NET Arrays Length
21 Apr, 2008 - 11:28 AM
Post #4

D.I.C Head
Group Icon

Joined: 28 Dec, 2007
Posts: 72


Dream Kudos: 50
My Contributions
I managed to find a solution of the problem, but this is not the important thing. My new question is not for arrays, but for collections. Is there any known reason that Treeview.Nodes could not receive any more Nodes. I have a string and the nodes in it are splitted by ;, then I use the .Split Method to convert them into different elements of one array. Then I use for each to add all elements as nodes to the Treeview but at some point, it stops and not all the elements are put as nodes. Anyone to help?
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 12:07AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month