newbie problem with array

  • Thread starter Thread starter eejit
  • Start date Start date
E

eejit

This is VBNET2005

I 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 said:
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.
 
\\\
Me.TextBox1.Lines = testarray
///

- or -

\\\
Me.TextBox1.Text = testarray(1)
///

depending on what you want to archieve.


Thankss that clears it up. Not sure what I was thinking.

eejit
 
Cor said:
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
array of strings and not an integer.

I was once searching for that lines property because it is in a mater of way
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
 
Back
Top