Read File To A List Box (VB)

srobinson

Newcomer
Joined
May 5, 2003
Messages
1
Read File To A List Box

I'm trying to create a VB .NET program that will read a text file and then populate a checked list box with the information. Here is what the text file looks like:

Server Transport Network Address
------------ --------- --------------------
SERVER01 TCP/IP XXX.XXX.XXX.XXX
SERVER02 TCP/IP XXX.XXX.XXX.XXX
SERVER03 TCP/IP XXX.XXX.XXX.XXX
SERVER04 TCP/IP XXX.XXX.XXX.XXX
SERVER05 TCP/IP XXX.XXX.XXX.XXX

Basically, what I am looking to do is to take the server names (i.e. SERVER01) and populate the checked list box. I will probably want to use an array to store the server names. Any help would be greatly appreciated. Thanks.
 
- Read the text line by line (TextReader.ReadLine)
- Parse each line using .Split method of String class
- If need to store the server name, user ArrayList
 
Here's a example of what Night is refering to:

'Populate CopperInsulation Array from file
Try
Dim file_Copper As String = DataCopper()
Dim stream_reader As New IO.StreamReader(file_Copper)
CopperInsulation = (Split(stream_reader.ReadToEnd, vbCrLf))
stream_reader.Close()
Catch exc As Exception
MsgBox(exc.Message, MsgBoxStyle.Exclamation, "Read Error")
End Try


'Return the dataCopper File Name
Private Function DataCopper() As String
Dim file_Copper As String = Application.StartupPath & "\Data\"
file_Copper &= "CInsulation.wir"
Return file_Copper
End Function

Hope this helps
Dan
 
Back
Top