Jump to content

vb.net list box question ?


Recommended Posts

ok i have a vb.net application with a list box i need this list box to get a list of names from a text file on my website witch i update ever day

 

i have tryed this on forum load

 

namelist.items.add ("http://www.mysite.com/namelist.txt" ) vb new line )

 

some guy told me that from another site

 

that all i need is it to load the name from the text file

 

any help will be great

Link to comment
https://forums.phpfreaks.com/topic/225547-vbnet-list-box-question/
Share on other sites

  • 3 weeks later...

You need to save your listbox infomation in a database like MSSQL ..

 

Then when you read your data something like this

 

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)_

Handles MyBase.Load

myConnection = New SqlConnection("server=localhost;uid=sa;pwd=;database=pubs")

'establishing connection. you need to provide password for sql server

Try

myConnection.Open()

'opening the connection

myCommand = New SqlCommand("Select price from discounts", myConnection)

'executing the command and assigning it to connection

dr = myCommand.ExecuteReader()

While dr.Read()

ListBox1.Items.Add(dr("price").ToString())

 

'displaying the data from the table

End While

dr.Close()

myConnection.Close()

Catch e As Exception

End Try

End Sub

'Then is you get a update save it to the database  then retrieve it

 

  • 1 year later...

You should read the text file line by line and add it it list box

 

http://vb.net-informations.com/files/vb.net_TextReader.htm

 

            Dim line As String

            Dim readFile As System.IO.TextReader = New StreamReader("C:\TextReader.txt")

            While True

                line = readFile.ReadLine()

ListBox1.Items.Add(line)

                If line Is Nothing Then

                    Exit While

                Else

                    MsgBox(line)

                End If

            End While

            readFile.Close()

 

bikitha.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.