combobox hlp
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
hello programmer(s)
<!--- shim need your help -->
i have a combobox and i want to load a textfile hosted on my host and also the texts should be organized
<!--- shim need your help -->
i have a combobox and i want to load a textfile hosted on my host and also the texts should be organized
Find my programs on Softpedia
If im thinking you want it like a sorta multiple choice system deal then you best bet would be to format the text into a listbox
and then populate that into the combobox alot easier that way and not to big of a code job
and then populate that into the combobox alot easier that way and not to big of a code job

First off you can sort all items of a combox box by setting its SORTING property to TRUE.
You will need to download the text file, read it line by line and then add them by using AddRange and read all lines of the text file
You will need to download the text file, read it line by line and then add them by using AddRange and read all lines of the text file
Code: Select all
For this you will need a combobox thats it. I wrote this example myself and I set the link to a pastebin file, just change it the link of your text file. It should be easy to understand, we download the text file and save it in the programs startup location, we read all lines of the text file and then add them to the combox, to sort the items we set the sorting property to true.Imports System.IO
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
'First off we need to downlaod the text file
My.Computer.Network.DownloadFile("http://pastebin.com/raw.php?i=xX9sSc7K", Application.StartupPath & "/text.txt", "", "", True, 100, True)
'here we download the file, set user and pass to default and we show the ui of the progress, 100 second timeout and we want to override the
'file if it exists already if it exists already so we have an updated version each time
'now we will read the text file and add items to comboxbox
ComboBox1.Items.AddRange(File.ReadAllLines(Application.StartupPath & "/text.txt"))
Catch ex As Exception
MsgBox("Error" & vbNewLine & ex.Message)
End Try
End Sub
End Class
My name is Tom | Visit my blog where I post new content every day! Tom's Daily Blog | MineCraft is awesome!
i dont want to download the file and read it i just want to do this
Code: Select all
Dim client As WebClient
Dim shim As String = client.DownloadString("http://website.com/file.txt")
ComboBox1.Items.Add(shim)
Find my programs on Softpedia
Did you still need help? Your code there will have everything in that one file added as one item
I am not particularly sure what you want out of this. If you didn't want the file to be store on the computer you can always use
I am not particularly sure what you want out of this. If you didn't want the file to be store on the computer you can always use
Code: Select all
My.Computer.FileSystem.DeleteFile("")
My name is Tom | Visit my blog where I post new content every day! Tom's Daily Blog | MineCraft is awesome!
Try This:
Dim r As IO.StreamReader
r = New IO.StreamReader("Path To Your File")
While (r.Peek() > -1)
ComboBox1.Items.Add(r.ReadLine)
End While
r.Close()
Dim r As IO.StreamReader
r = New IO.StreamReader("Path To Your File")
While (r.Peek() > -1)
ComboBox1.Items.Add(r.ReadLine)
End While
r.Close()
Is it possible for you to tell is what you are wanting this code to do and also giving us a link to the file so we can attempt to code up wat you want
visualtech wrote:Try This:thanks but its on internet
Dim r As IO.StreamReader
r = New IO.StreamReader("Path To Your File")
While (r.Peek() > -1)
ComboBox1.Items.Add(r.ReadLine)
End While
r.Close()
Find my programs on Softpedia
Copyright Information
Copyright © Codenstuff.com 2020 - 2023