|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
newbie problem with arrayI feel like I'm missing something really obvious here. I keep getting the error "Value of type 'string' cannot be converted to '1 dimensional array of string'" Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim inputstream As New System.IO.StreamReader("c:\testfile.txt") Dim line As String line = inputstream.ReadLine() Dim testarray() As String = Split(line) TextBox1.Lines = testarray(1) inputstream.Close() End Sub End Class Any help appreciated. eejit EEjit,
I think that you can do > Dim testarray() As String = Split(line) Textbox1.text = testarray(1)> > TextBox1.Lines = testarray(1) or Textbox1.lines = testararray.length http://msdn2.microsoft.com/en-us/library/hz0yf4h5(en-US,VS.80).aspx I hope this helps, Co Cor Ligthert [MVP] wrote:
> Textbox1.lines = testararray.length This will result in an error as the Lines property of the TextBox is an> array of strings and not an integer. Chris,
> This will result in an error as the Lines property of the TextBox is an I was once searching for that lines property because it is in a mater of way > array of strings and not an integer. the equivalent to the multiline option. I could not find it anymore. This showes that it was not deleted, however completely removed from my memory. Thanks for pointing me on this. :-) Cor
Show quote
Hide quote
"eejit" <ee***@canada.com> schrieb: \\\> I keep getting the error "Value of type 'string' cannot be converted > to '1 dimensional array of string'" > > > Public Class Form1 > > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e > As System.EventArgs) Handles Button1.Click > > > > > Dim inputstream As New > System.IO.StreamReader("c:\testfile.txt") > > Dim line As String > > line = inputstream.ReadLine() > > Dim testarray() As String = Split(line) > > TextBox1.Lines = testarray(1) Me.TextBox1.Lines = testarray /// - or - \\\ Me.TextBox1.Text = testarray(1) /// depending on what you want to archieve. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> On Sun, 5 Feb 2006 13:00:56 +0100, "Herfried K. Wagner [MVP]"
<hirf-spam-me-here@gmx.at> wrote: Show quoteHide quote >"eejit" <ee***@canada.com> schrieb: Thankss that clears it up. Not sure what I was thinking.>> I keep getting the error "Value of type 'string' cannot be converted >> to '1 dimensional array of string'" >> >> >> Public Class Form1 >> >> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e >> As System.EventArgs) Handles Button1.Click >> >> >> >> >> Dim inputstream As New >> System.IO.StreamReader("c:\testfile.txt") >> >> Dim line As String >> >> line = inputstream.ReadLine() >> >> Dim testarray() As String = Split(line) >> >> TextBox1.Lines = testarray(1) > >\\\ >Me.TextBox1.Lines = testarray >/// > >- or - > >\\\ >Me.TextBox1.Text = testarray(1) >/// > >depending on what you want to archieve. eejit
Newbie Question 2, Reference To Controls On A Form
problem with relative paths in VS/VB.net making image click fire codebehind function? current working directory problem Problem Communicating Between Forms Calling Program A from Program B help with multiple forms on asp.net 1.1 page, please Newbie Question Saving Projects late bound form reference Some error apper to me in my declerations |
|||||||||||||||||||||||