Each line from textbox to array

bunze

Well-known member
Joined
Aug 4, 2005
Messages
52
Location
Adirolf
Programming Experience
1-3
edit: sorry for misleading title

I've been trying for a while but I can't get it. Is there any other way to do this but much easier?

TextBox1.Text = "pc1036%2iCYBJg76dZCq5W" & vbNewLine & _
"pc1037%3EiXP52z8CfLZgm" & vbNewLine & _
"pc103%tWt73oKijT9Hf2P" & vbNewLine & _
"pc1030%Mxy36rNFoW8d5jH"

Basicly I have that but I have thousands of them and after typing " & vbNewLine & _ almost 200 times I'm tired of it.

I have them in a text file like this

pc1036%2iCYBJg76dZCq5W
pc1037%3EiXP52z8CfLZgm
pc103%tWt73oKijT9Hf2P
pc1030%Mxy36rNFoW8d5jH

Please?
 
Last edited:
If they are in your text file as separate lines then there's no issue because the file already contains the line breaks. Just read the whole file into the TextBox:
VB.NET:
Dim sr As New StreamReader("file path here")

myTextBox.Text = sr.ReadToEnd()
sr.Dispose()
 
Thank you. I imported System.IO

but I get this

'System.IO.StreamReader.Protected Overrides Overloads Sub Dispose(disposing As Boolean)' is not accessible in this context because it is 'Protected'.

I don't know how to fix that.
 
Hang on a minute! I WAS right the first time. You can call Close but there's nothing whatsoever wrong with calling Dispose. The code I provided calls Dispose with no arguments. Your error message says that you're incorrectly calling Dispose with a Boolean argument. Nowhere did I suggest that you should do that.
 
Hmmm... just took a look at the doco and it says that that overload of Dispose is new in .NET 2.0, so it must not have been Public previously. Sorry about that. Anyway, just call Close instead and it will work fine.

...or it just didn't exist. I just had a look at the 2003 doco and there is only one overload of Dispose that was Protected and had one Boolean argument. Maybe Dispose() was added to support Using statements. Whatever, Close will work in any version.
 
no more confusion
VB.NET:
Dim sr As New StreamReader("file path here")

myTextBox.Text = sr.ReadToEnd()
sr.Close()
 
Back
Top