0

I am trying to display the values of strings, but all i see in my output is System.String[] - which is pretty darned useless!

Here is my code:

    Dim pageOfText As String = SplitString(text, 750).ToString()
    Console.WriteLine(pageOfText.ToString)
4
  • ToString() is a method, so it needs the brackets to be included on the second line. Commented Aug 27, 2014 at 13:23
  • What's SplitString? Looks like pageOfText should be an array, try declaring it as such. Commented Aug 27, 2014 at 13:24
  • @Psychemaster - no it doesn't VB.NET doesn't care whether you have brackets on methods or not Commented Aug 27, 2014 at 13:28
  • Calling ToString() on an array returns System.String[]. Don't call this and iterate the array. Commented Aug 27, 2014 at 13:32

3 Answers 3

5

Without knowing the implementation of the SplitString method this is an educated guess that SplitString returns a String Array.

You are using .ToString on this array which correctly returns System.String[] (Equivalent to System.String() in VB)

You should iterate through the strings in the array instead. Something like this:

For each s As String in SplitString(text, 750)
    Console.WriteLine(s)
Next
Sign up to request clarification or add additional context in comments.

Comments

0

It looks like you could be trying for one of two things, so I will answer both: (Note that I'm assuming text is your variable name.)

1. Try using the .NET function String.Split like this:

Dim strSplitString = text.Split(";"c)
For Each strOutput In strSplitString
    Console.WriteLine(strOutput)
Next

To use String.Split, use the Split method of the string you want to split and pass the character you want to use as the separator as an argument. This produces a string array that you can then irritate through with For Each . . .

Note that if you want String.Split to accept a string as a separator, you must also specify how many strings it may include and whether it may include blank strings.

Dim strSplitString = text.Split("750", 750, StringSplitOptions.RemoveEmptyEntries)

2. Try using the .NET function String.SubString to retrieve the first 750 characters of your string.

Dim strSplitString = text.SubString(0, 750)
Console.WriteLine(strSplitString)

Comments

0

I guess SplitString function split your text to Integer (750) pieces and store them as an array of String so if you want to display all of them iterate in the array

For i as Integer to pageOfText.GetUpperBound(0)
Console.WriteLine("Trimmed text: " + pageOfText(i).toString() & Environment.NewLine) Next

And you can see all text in the page

hope this was helpful

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.