Link to home
Start Free TrialLog in
Avatar of f_asmaa
f_asmaa

asked on

StringBuilder

TextBox1.text = stringBuilderObject.ToString()

This code always return the first added character array only. How to return all charater arrays added to the String Builder?
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

How did you feed stringBuilderObject ? You should have used the .Append method. Show us your code.
Avatar of f_asmaa
f_asmaa

ASKER

Dim sb As New StringBuilder()
Dim data(1024) As Char
Dim nBytes As Integer

Do
  nBytes = sr.Read(data, 0, 1024)
  sb.Append(data)
Loop While nBytes = 1024

TextBox1.Text = sb.ToString

'sr is a stream reader
'TextBox1 only shows the first appended data. i.e the first 1024 characters. If I change 1024 into 2048 TextBox1 shows the first 2048 characters.
change to
Loop While nBytes > 0
Avatar of f_asmaa

ASKER

No effect
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of f_asmaa

ASKER

Yes your code works but I want to understand why do you use brackets around Char and String?
You can remove them. That was copied from a website. These brackets are normally used when you need element names (variables, methods, enums, ...) with names that are normally invalids.