adding to list box

Donorottie
07-08-2003, 08:36 AM
I am trying to add to a list box from two different sources. In the first case I am adding from lstbox1 to lstbox2. I have this working pretty well. Next I want to add from a txtFile to lstBox2. The text file has the name of a pdf file that I want to have showup in the lstbox2.

Now here is what happens:
If I add the pdf file to lstbox2 first I then can add any item from lstbox1 to lstbox2 but I can't add more than 1 pdf file.
If I add an item from lstbox1 to lstbox2 first then I can't add any pdfs at all.

code to add lstbox items

'add News Developments to list box 2

Private Sub cmdAddNews_Click()
Dim sAdd As String
Found_It = False

Screen.MousePointer = vbHourglass

If lstNews1.ListIndex <> -1 Then
sAdd = lstNews1

For iCount = 0 To lstNews2.ListCount - 1

lstNews2.ListIndex = iCount

If sAdd = lstNews2 Then
Found_It = True
Exit For
End If
Next

If Found_It Then
MsgBox "This item has already been selected"
lstNews2.ListIndex = -1
Else
lstNews2.AddItem lstNews1.Text
iCount = lstNews2.NewIndex
lstNews2.ItemData(lstNews2.NewIndex) = lstNews1.ItemData(lstNews1.ListIndex)

Call CreateConnection(objConn)

sSQL = "INSERT INTO CAMPAIGNDETAILS(cd_id, cd_type, table_id_number) Values ('" & txtPresentationID.Text & "',('NEWS')," & lstNews2.ItemData(iCount) & ")"
objConn.Execute (sSQL)

lstNews2.ListIndex = -1
End If

End If

Screen.MousePointer = vbDefault

End Sub



code to add pdf

Dim sAdd As String
Found_It = False

sAdd = TxtFile1

For iCount = 0 To lstNews2.ListCount - 1

lstNews2.ListIndex = iCount

If sAdd = TxtFile1 Then
Found_It = True
Exit For
End If
Next

If Found_It Then
MsgBox "This item has already been selected"
lstNews2.ListIndex = -1
Else
lstNews2.AddItem TxtFile1.Text
lstNews2.ListIndex = -1

'/////////////////////// COPY PDF FILE TO PDF FOLDER ////////////////////////
FileCopy Dir1.Path & "\" & File1.FileName, App.Path & "\" & "pdfs" & "\" & File1.FileName

End If

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum