Skip to content
WJunction - Webmaster Forum

how to load text from file

Status
Not open for further replies.
hi, i wanna load text from file to multiple txt box eg...

name
age
gender

i got this code + the file can be: chris.txt, john.txt basically can be anything wit ".txt" but the filename is in the treeview, but there is multiple nodes.?

anyways:

Code:
Dim myDir As IO.StreamReader( i dunno the path, tried app.startuppath )

Dim txt As String

For each file in IO.StreamReader("*.txt")

Next

then something like, cnt remember as i deleted it, but:
Code:
txt.Stream.ReadLine.Contains("name=")

txtbox.text = txt

this dnt work at least i get no errors.

its vb.net 2010

any help?
 

2 comments

Dim str1 As String = My.Computer.FileSystem.ReadAllText(Application.StartupPath & "\name.txt")
Dim str2() As String = str1.Split(Environment.NewLine)
For i = 0 To str2.Count - 1 Do
Dim str3() As String = str2( i).Split("=")
If str3( 0).ToString = "name" Then
TextBoxName.Text = TextBoxName.Text & Environment.NewLine & str3(1)
ElseIf str3( 0).ToString = "lastname" Then
TextBoxLastname.Text = TextBoxLastname.text & Environment.NewLine & str3(1)
End If
Next
 
Status
Not open for further replies.

About the author

C
Banned · Joined
901
Messages
17
Reactions
18
Points
Grow your business

Advertise on WJunction

Connect with an established international community of webmasters, hosting providers, developers and online entrepreneurs.

  • Premium & Premium+ Sticky
  • Dedicated section banners
  • Site-wide banner advertising
Explore advertising options
Back
Top Bottom