Hello everyone. I am updating a web scrapper and right now I keep all the links I scrap in a txt file, but for various websites I have various txt files, so I would like to modify if possible, a block of code from an earlier project where a common dialog box is opened and the user picks a txt file and the txt file is loaded into an array of textboxes. I would like to modify it so instead of being loaded into text boxes, it is loaded into a listbox.
Here is the old code.
As you can see the CustomQ is the name of the boxes, but the name of the list is called WebsiteList. Would this just be a matter of loading a textfile to a listbox where the Do Loop begins? or would it end up loading it over and over in the same listbox? I don't need it to load more than once. lol :) Thanks!
Here is the old code.
VB Code:
Private Sub Open_Click() ' ' Requires a Microsoft Common Dialog Control drawn on the form ' Named cd ' Dim strData As String Dim strQ() As String Dim intI As Integer Dim intFile As Integer ' ' Set up the Common Dialog initial Directory ' to the application path. Filter for Text and All files ' Prompt the user to select a file ' cd.InitDir = App.Path cd.Filter = "Text Files(*.txt)|*.txt|All Files(*.*)|*.*" cd.DialogTitle = "Select Question File" cd.ShowOpen If cd.FileName <> "" Then ' ' If the user selected a file ' open and read the entire contents ' then split it into records ' intFile = FreeFile Open cd.FileName For Input As intFile strData = Input(LOF(intFile), intFile) Close intFile strQ = Split(strData, vbNewLine) ' ' Populate the texbox array with the questions ' (either the number of textboxes in the control array or ' number of questions, which ever is the smaller) ' Do CustomQ(intI).Text = strQ(intI) intI = intI + 1 Loop Until intI > CustomQ.UBound Or intI > UBound(strQ) End If End Sub
As you can see the CustomQ is the name of the boxes, but the name of the list is called WebsiteList. Would this just be a matter of loading a textfile to a listbox where the Do Loop begins? or would it end up loading it over and over in the same listbox? I don't need it to load more than once. lol :) Thanks!