Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove one item fr combo box 1

Status
Not open for further replies.

Vec

IS-IT--Management
Jan 29, 2002
418
US
Basically my code is doing what I want it too, except for one small thing, it is adding one to many of something at the end of a combo box.
As you can see by the code below, it is reading from approved.txt and populating a combo box with the entries it finds, the approved.txt file contains one entry per line of domain names and I need them to be just the yahoo.com part of for instance because I plan to add a url filter, but that is another story. So when this code is run, it produces a combo box like this:

Notice the extra
Code:
[URL unfurl="true"]http://www.[/URL]
at the end? Well I want it to vanish.


Code:
Private Sub Form_Load()
Code:
Dim  result As Long, intFreeFile As Integer, sText As String, txt As String, inp_String As Integer, UrlLead As String

Code:
UrlLead = "[URL unfurl="true"]http://www."[/URL]

Code:
Combo1.Width = Me.ScaleWidth
Code:
result = SetWindowPos(frmMain.hwnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
Code:
    App.TaskVisible = False
Code:
        Load_Ban

Code:
On Error Resume Next
Code:
intFreeFile = FreeFile
Code:
Open App.Path & "\approved.txt" For Binary Access Read As #intFreeFile
Code:
      Do Until EOF(intFreeFile)
Code:
         Line Input #intFreeFile, txt
Code:
         txt = UrlLead + txt
Code:
         Combo1.AddItem txt
Code:
         txt = vbNullString
Code:
      Loop
Code:
Close #intFreeFile

Code:
End Sub

-------------------------------------------------------------------------
-------------------------------------------------------------------------

"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former."
- Albert Einstein (1879-1955)
 
Try this instead..

While Not EOF(intFreeFile)
Line Input #intFreeFile, txt
txt = UrlLead + txt
Combo1.AddItem txt
txt = vbNullString
Wend

if that doesnt remove the unwanted input then try...

Combo1.RemoveItem Combo1.ListCount - 1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top