Posted on 2004-11-21
Medium Priority
Last Modified: 2010-04-23
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?
Question by:f_asmaa
  • 4
  • 3
LVL 70

Expert Comment

by:Éric Moreau
ID: 12638988
How did you feed stringBuilderObject ? You should have used the .Append method. Show us your code.

Author Comment

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

  nBytes = sr.Read(data, 0, 1024)
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.
LVL 70

Expert Comment

by:Éric Moreau
ID: 12643035
change to
Loop While nBytes > 0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.


Author Comment

ID: 12643071
No effect
LVL 70

Accepted Solution

Éric Moreau earned 200 total points
ID: 12643149
This code is working well for me:

            Dim read(256) As [Char]

            ' Read 256 charcters at a time    .
            Dim intCount As Integer = readStream.Read(read, 0, 256)
            Do While intCount > 0
                ' Dump the 256 characters on a string and display the string onto the console.
                Dim str As New [String](read, 0, intCount)
                intCount = readStream.Read(read, 0, 256)

Author Comment

ID: 12643373
Yes your code works but I want to understand why do you use brackets around Char and String?
LVL 70

Expert Comment

by:Éric Moreau
ID: 12643693
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.

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question