darklexus2k9 Posted January 24, 2011 Share Posted January 24, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/225547-vbnet-list-box-question/ Share on other sites More sharing options...
Leftfield Posted February 9, 2011 Share Posted February 9, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/225547-vbnet-list-box-question/#findComment-1171943 Share on other sites More sharing options...
bikithalee Posted June 4, 2012 Share Posted June 4, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/225547-vbnet-list-box-question/#findComment-1351196 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.