Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.