Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Listview - DragDrop Multiple Items


I have the following code that successfully will drag & drop one item at a time, but doesn't work all the time if multiple rows are selected?
When I start to drag, sometimes nothing happens.

Anybody point me in the right direction please?


Code:
Private Sub lvwSelected_OLEDragDrop(Data As MSComctlLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)
On Error GoTo ErrTrap

Dim i As Long
Dim lvwItem As ListItem

For i = 1 To lvwSource.ListItems.Count
If lvwSource.ListItems(i).Selected = True Then
Set lvwItem = lvwSelected.ListItems.Add(, , lvwSource.ListItems(i).Text)
lvwItem.SubItems(1) = lvwSource.ListItems(i).SubItems(1)
lvwItem.SubItems(2) = lvwSource.ListItems(i).SubItems(2)
'remove original item
lvwSource.ListItems.Remove i
End If
Next

Also, when dragging multiple items across, and removing the original item, I now get an error because the ListItem.Count is now out of bounds.
How would I handle this?
Would I add 1 to the value of 'i' before the next loop?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Get DragDrop Items.Index Or Item(Name) On ListView With Scrollbar?
Hiya's folks

Here's my bug
Code:
Private Sub lstView1_OLEDragDrop(Data As MSComctlLib.DataObject, Effect As Long, _
Button As Integer, Shift As Integer, X As Single, Y As Single)

    myIndexItem = lstView1.ListItems.Item(Int(Y / 17) + 1)

End Sub


I'm using this statement to get the item name, but when the V-scrollbar is scrolled down...
I can't get the good item since I'm using the Y parameter
Any idea how to get the index of the first item displayed in listview when
the scrollbar is scrolled?
Or is there a way to get the "visual" name of the item I drag on?

Thx!!

Add Items To A Listview Multiple Columns
Hi... I have a listview with 3 columns... how can i add items to the second and the third column? i know it's a stupid question but i can't solve it


Thanks in advance

simons

Moving Multiple Listview Items Up Or Down At Once
Hi, does anybody know how to move multiple selected listview items up or down at once?

I found the subs below, but they only move one item up or down, even if I have selected multiple items.

Thanks.


vb Code:
Private Enum menmDirections    MoveUp = 1    MoveDown = 2End Enum Private Sub MoveItem(ByVal penmDirection As menmDirections)Dim lvwItem     As ListItemDim lvwNew      As ListItemDim lvwSubItem  As ListSubItemDim lngIndex    As Long    Set lvwItem = lstView.SelectedItem    If Not (lvwItem Is Nothing) Then        If penmDirection = MoveUp Then            lngIndex = lvwItem.Index + 2        ElseIf penmDirection = MoveDown Then            lngIndex = lvwItem.Index - 1        End If        If lngIndex > 0 And lngIndex <= lstView.ListItems.Count + 1 Then            Set lvwNew = lstView.ListItems.Add(lngIndex, , lvwItem.Text)            For Each lvwSubItem In lvwItem.ListSubItems                lvwNew.ListSubItems.Add , lvwSubItem.Key, lvwSubItem.Text, lvwSubItem.ReportIcon, lvwSubItem.ToolTipText            Next lvwSubItem            lvwNew.Selected = True            Set lvwNew = Nothing            lstView.ListItems.Remove lvwItem.Index        End If        Set lvwItem = Nothing    End IfEnd Sub



vb Code:
Private Sub MoveUp(lv As ListView)    Dim itm As ListItem, itmNew As ListItem, i As Long    If lv.SelectedItem.Index > 1 Then        Set itm = lv.SelectedItem        Set itmNew = lv.ListItems.Add(itm.Index - 1, , itm.Text, itm.Icon, itm.SmallIcon)        For i = 1 To itm.ListSubItems.Count            With itm.ListSubItems(i)                Call itmNew.ListSubItems.Add(, .Key, .Text, .ReportIcon, .ToolTipText)            End With        Next        lv.ListItems.Remove itm.Index        itmNew.Selected = True        lv.SetFocus    End IfEnd Sub Private Sub MoveDown(lv As ListView)    Dim itm As ListItem, itmNew As ListItem, i As Long    If lv.SelectedItem.Index < lv.ListItems.Count Then        Set itm = lv.SelectedItem        Set itmNew = lv.ListItems.Add(itm.Index + 2, , itm.Text, itm.Icon, itm.SmallIcon)        For i = 1 To itm.ListSubItems.Count            With itm.ListSubItems(i)                Call itmNew.ListSubItems.Add(, .Key, .Text, .ReportIcon, .ToolTipText)            End With        Next        lv.ListItems.Remove itm.Index        itmNew.Selected = True        lv.SetFocus    End IfEnd Sub

Multiple Selected Items In A Listview
Hello, how can I find out how many selected items there are in a listview?

I'm showing a popup menu when the user right-clicks on an item, but I need to know if only 1 item is selected, so I can disable a menu option.

I've tried this, but it doesn't work.


VB Code:
If ListView.SelectedItem < 2 Then mnuCopyMultiple.Enabled = False

Dragging Multiple Items From A Listview
i have some code to let users drag an item from a listview onto a treeview node, which works fine, but now i want to let them drag multiple items.

the problem is that when then select a bunch of items, then drag them to the treeview, it leaves only the last item they clicked on selected (as if they selected them, then just left-clicked one of them). is there a way to keep them all selected?

also, just out of interest, is there a way to make the drag icon include some text from each selected listview item along with an icon (like when you drag multiple files in windows explorer)?

thanks for any help

Remove Multiple Items From ListView
I've got a ListView control with the MultiSelect property set to True and would like to remove all of the selected items only. I've looked at some of the threads concerning this issue but am still having trouble. I can remove a single selected item but not all of the selected items. My code is as follows:


Code:
Private Sub cmdRemove_Click()

Dim I As Integer

For I = 1 To lstPlot.ListItems.Count
If lstPlot.ListItems(I).Selected = True Then
lstPlot.ListItems.Remove (I)
End If
Next I

End Sub


What am I missing?

Thanks for your help!

Multiple Select Items In Listview
im having a problem in listview. ther ar 2 listviews for Excel and server. the user will select fields in th excel lisview he want to upload in server lisview. it upload a field if the user only select 1 field. but if it highlights many fields it only copy the lastselected fields the other fields highlighted dont work. heres my code:

j = LVExcel.ListItems.Count
 For i = j To 1 Step -1
  If LVExcel.ListItems(i).Selected = True And LVDatabase.ListItems(i).Selected = True Then
        Set rs1 = New ADODB.Recordset
        destinationtble = "select * from [user]"
        rs1.Open destinationtble, gcn, adOpenKeyset, adLockOptimistic
           Do While Not RS.EOF
              rs1.AddNew
              rs1.Fields(LVDatabase.SelectedItem.Text) = RS.Fields(LVExcel.SelectedItem.Text)
              rs1.Update
              RS.MoveNext
           Loop
          Set RS = Nothing
  End If
next i

Please Help Me With Drag-n-Drop Of Multiple Items From One Listview To Another.
Hello!

I'm facing a problem with Listview Drog and Drop of multiple items from one listview to another listview. When I try to Drag only one single item, the item is dragged without any problem. However, when the multiple selected items are dragged, the Listview on which the items are dropped, receives information about only one item and not all selected items. The item, about which the information is received, is the same on which I click and hold mouse to start drag action. So, it looks like even though multiple items are selected in a listview, while executing the Drag-Drop action, listview treats it as single item selected!

Is this a default behavior of Listview or am I missing/doing anything wrong? Any work-around for this (seems like default) behavior of Listview? I searched for it and got a code example at http://btmtz.mvps.org/listview/ where the author has demonstrated Drag-Drop of multiple items. However, the code is specifically restricted to re-arranging items within same Listview and the information is transported via Drag-Drop to another Listview, upon which the items are dropped.

To help you all to get a better insight of my problem, I have attached a Demo of Listview Drag-n-Drop. Please see the project and you will see that when one item is dragged from left side Listview to right side Listview, no problem for VB to allow me to do it! However, when you select multiple items in left side Listview and try dragging those to right side Listview, only one item is dragged. Please let me know if I'm doing anything wrong here and please help me to get this stuff to work!

Waiting for your valuable reply ...

Regards,

Ruturaj.

Drag Multiple Items From Listview To Treeview
Does anyone have some good sample code for how to
drag multiple listviewitems to an treeview?!

I cant figure it out...

Regards

Peter

Show Multiple Items In Listview Taken From Database
How would I show multiple items from an Access database in a listview?

Example: Let's say my database looks like this:

Sender Subject Date
me@isp.com Some Subject 1-13-00 7:59AM
you@otherisp.com Some other subject 7-30-01 8:00AM

I want to load both items into a listview. My current procedure only loads one item at a time. Here is the procedure:


Code:
Dim Recordset As ADODB.Recordset
Select Case Node.Text
Case "Trash"
If Recordset.EOF = True Then Exit Sub
lvwMail.ListItems.Clear
With lvwMail.ListItems.Add(, , Recordset!Sender)
.SubItems(1) = Recordset!Subject
.SubItems(2) = Recordset!Date
End With
End Select

How To Move Multiple Selected Items To New ListView
I have 2 ListView Controls. I need to move multiple selected items from ListView1 to ListView2.

How would I go about doing this?

Please Help Me With Drag-n-Drop Of Multiple Items From One Listview To Another.
Hello!

I'm facing a problem with Listview Drog and Drop of multiple items from one listview to another listview. When I try to Drag only one single item, the item is dragged without any problem. However, when the multiple selected items are dragged, the Listview on which the items are dropped, receives information about only one item and not all selected items. The item, about which the information is received, is the same on which I click and hold mouse to start drag action. So, it looks like even though multiple items are selected in a listview, while executing the Drag-Drop action, listview treats it as single item selected!

Is this a default behavior of Listview or am I missing/doing anything wrong? Any work-around for this (seems like default) behavior of Listview? I searched for it and got a code example at http://btmtz.mvps.org/listview/ where the author has demonstrated Drag-Drop of multiple items. However, the code is specifically restricted to re-arranging items within same Listview and the information is transported via Drag-Drop to another Listview, upon which the items are dropped.

To help you all to get a better insight of my problem, I have attached a Demo of Listview Drag-n-Drop. Please see the project and you will see that when one item is dragged from left side Listview to right side Listview, no problem for VB to allow me to do it! However, when you select multiple items in left side Listview and try dragging those to right side Listview, only one item is dragged. Please let me know if I'm doing anything wrong here and please help me to get this stuff to work!

Waiting for your valuable reply ...

Regards,

Ruturaj.

Please Help Me With Drag-n-Drop Of Multiple Items From One Listview To Another.
Hello!

I'm facing a problem with Listview Drog and Drop of multiple items from one listview to another listview. When I try to Drag only one single item, the item is dragged without any problem. However, when the multiple selected items are dragged, the Listview on which the items are dropped, receives information about only one item and not all selected items. The item, about which the information is received, is the same on which I click and hold mouse to start drag action. So, it looks like even though multiple items are selected in a listview, while executing the Drag-Drop action, listview treats it as single item selected!

Is this a default behavior of Listview or am I missing/doing anything wrong? Any work-around for this (seems like default) behavior of Listview? I searched for it and got a code example at http://btmtz.mvps.org/listview/ where the author has demonstrated Drag-Drop of multiple items. However, the code is specifically restricted to re-arranging items within same Listview and the information is transported via Drag-Drop to another Listview, upon which the items are dropped.

To help you all to get a better insight of my problem, I have attached a Demo of Listview Drag-n-Drop. Please see the project and you will see that when one item is dragged from left side Listview to right side Listview, no problem for VB to allow me to do it! However, when you select multiple items in left side Listview and try dragging those to right side Listview, only one item is dragged. Please let me know if I'm doing anything wrong here and please help me to get this stuff to work!

Waiting for your valuable reply ...

Regards,

Ruturaj.

Please Help Me With Drag-n-Drop Of Multiple Items From One Listview To Another.
Hello!

I'm facing a problem with Listview Drog and Drop of multiple items from one listview to another listview. When I try to Drag only one single item, the item is dragged without any problem. However, when the multiple selected items are dragged, the Listview on which the items are dropped, receives information about only one item and not all selected items. The item, about which the information is received, is the same on which I click and hold mouse to start drag action. So, it looks like even though multiple items are selected in a listview, while executing the Drag-Drop action, listview treats it as single item selected!

Is this a default behavior of Listview or am I missing/doing anything wrong? Any work-around for this (seems like default) behavior of Listview? I searched for it and got a code example at http://btmtz.mvps.org/listview/ where the author has demonstrated Drag-Drop of multiple items. However, the code is specifically restricted to re-arranging items within same Listview and the information is transported via Drag-Drop to another Listview, upon which the items are dropped.

To help you all to get a better insight of my problem, I have attached a Demo of Listview Drag-n-Drop. Please see the project and you will see that when one item is dragged from left side Listview to right side Listview, no problem for VB to allow me to do it! However, when you select multiple items in left side Listview and try dragging those to right side Listview, only one item is dragged. Please let me know if I'm doing anything wrong here and please help me to get this stuff to work!

Waiting for your valuable reply ...

Regards,

Ruturaj.

ListView - DragDrop
Hi,

I have some problems implementing OLE Drag and Drop in a ListView.

I want to use Drag and Drop to order items manually. To do so I need to now where I Drop the drag (which item...) I use HitTest(x,y) to know where my cursor is, but I think it is all messed up...

OLEDragOver, OLEDragDrog returns X and Y as single but HitTest don't seem to use the same references... (Pixels, Twips,... )

Need help...

ListView DragDrop
I have a ListView on one of my forms, its setup as a report view for multiple reasons i wont get into here..

What im trying to do is make it so that the user can select an item, and drag and drop it into a multi-line text box, and it will display the text in the text box from the first column of the item they dragged over.

The problem is, when the user does this, it removes the item from the ListView.. Is there a way to make it automatically copy the item instead of moving it?

All i did to setup the drag and drop is change the OLEDragMode of the ListView to Automatic, and the OLEDropMode of the text box to Automatic...

Ive never used drag and drop before so im kinda clueless...

Dragdrop With A Listview
I've got a listview in report mode (it's a small table, really), and I want the user to be able to change the order of the rows. They should be allowed to click on row 5, drag it up a ways, and drop it between rows 1 and 2 (those are arbitrary numbers). All I want is to allow dragdrop support to the report mode of the listview, but it's eluding me.

Thanks in advance,

bob

ListView OLE DragDrop?
I have a listview where items can be "drag/dropped" into. The problem is that I only know how to add the items to the end of list. How can I insert an item where the drag stops. So if i release the mouse at index 10 in the listview, how do I tell it to insert the Drag data there and not just add it to the end? Thanks in advance!

DragDrop And Listview Control
Does anyone know the trick to dragdrop one file or multiple files from a browserscreen in Windows into a ListView control within my application.

The properties of the selected files should be added to te following properties of the newly added listitems:

Only the filenames ----> ListView.ListItem(x).Text
Path & filenames ------> ListView.ListItem(x).Key

Many thanks in advance,

VbHenk

Dragdrop Moving Wrong Item In Listbox(aborted Dragdrop Idea)
I am using dragdrop in a list box(checkbox style) to move items around but sometimes it picks up the item below the one I selected instead of the one I clicked on. ANy ideas? heres the code I'm using

Code:

Private Sub lstFields_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If (Button And vbLeftButton) = vbLeftButton Then
nDragIndex = Y Me.TextHeight("Xyz")
If nDragIndex >= 0 And nDragIndex < lstFields.ListCount Then
blnDraging = True
End If
End If
End Sub

Private Sub lstFields_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim nIndex As Integer
Dim sItem As String

If (Button And vbLeftButton) = vbLeftButton Then
If blnDraging = True Then
nIndex = Y Me.TextHeight("Xyz")
If nIndex > lstFields.ListCount - 1 Then
nIndex = lstFields.ListCount
ElseIf nIndex < 0 Then
nIndex = 0
End If
If nIndex <> nDragIndex Then
sItem = lstFields.List(nDragIndex)
lstFields.RemoveItem nDragIndex
lstFields.AddItem sItem, nIndex
End If
End If
blnDraging = False
End If
End Sub


This is my first post with code in it so I hope I did it right, sorry if I didn't.

Sunflower Queen

Combine 2 Listview Items Into One Listview
I have 2 listviews that have a different listitems.

ex.

LV 1 LV 2
1. A 1. B
2. C 2. D
3. E 3. F


Is there a way to combine the 2 to another listview so that they all look like this with out doubles of matching items?

ex.

LV 3

1. A
2. C
3. E
4. D
5. E
6. F

Combine 2 Listview Items Into One Listview
I have 2 listviews that have a different listitems.

ex.
________________
LV 1 l LV 2 l
l l
1. A l 1. B l
2. C l 2. D l
3. E l 3. F l
_______l_________l

Is there a way to combine the 2 to another listview so that they all look like this with out doubles of matching items?

ex.
_______
LV 1 l
1. A l
2. C l
3. E l
4. D l
5. E l
6. F l
_______l

Multiple Items In A Collection
Hello all,

I've got a (simple?) question that has me flabberghasted.
I'm trying to program a simple pacman clone.


The 'Maze' object has a collection of ghosts, that get filled like this:

For col = 0 To 1 'create some ghosts for testing
For row = 0 To 1

Set Ghost = New clsGhost

Ghost.PosX = col * 14 * 48
Ghost.PosY = row * 8 * 48
Ghost.Speed = 20 * row + 40 * col

Ghosts.Add Ghost

Next row
Next col


If the ghost is to walk around in the maze, it has to know about possible
directions, so the ghost can raise an event to its parent (the maze):

RaiseEvent GetDirection( iPosX SQUARE_WIDTH + 1, _
iPosY SQUARE_HEIGHT, _
MazeDir)


Now, if I create only ONE ghost, then it will run happily around the maze
However, creating MORE ghosts causes the program to skip the 'RaiseEvent' instruction. ( detected during single stepping)

How can I make the 'RaiseEvent' instruction work for multiple instances of the ghost class?

TIA,
Alvatrus

Multiple Listbox Items
I have a standard listbox that instead of only one item per line I have 3 items per line such as: Quantity, ItemNum, Price. I want to add these items to their matching columns in my database of quantity, ItemNum, and Price.

Is there a column property of the listbox that I can use to extract the Items individually?


rs is my recordset

Do while rs.Eof = False
list1.addnew = rs!Quantity
Loop

This only gets one item per line.

Searching For Multiple Items
is there a way to search for more than one item at a time?

ex text

i have a red fox
i own a red car
i have six blue coats

and my search terms are: car and blue

result

i own a red car
i have six blue coats

this might be a pretty dumb ?, but then i am not a code guru

Parse Multiple Items; Help!
I have another problem, I want to be able to parse multiple userID's from a page of online users, the code I want to get between is:

Code:


Code:
_vchat_174375447'


The userID being 174375447.

I used:


Code:
Dim StrPage As String
StrPage = Inet1.OpenURL("http://www.stickam.com/whosLive.do?listType=live")

StrToken = GetBetween(1, StrPage, _
"vchat_", "'", vbTextCompare)

lstGen.AddItem (StrToken)


The code parses the string of text correctly, but my situation is that I have more than one userID in a page. So I don't need it stop after finding one, I need it to find one userID, add it to a listbox, then move onto another userID in the data, then add it to a listbox and so on. In advance of acknowledgment, each userID has the same beginning and ending:


Code:
_vchat_userID'


Thank you,
mikeyy.

Lists And Getting Rid Of Multiple Items
Hi,

Is there any way to remove multiple items for a list. For example, the list:

A
H
A
A
K

Is there any way I could just turn it into:

A
H
K

...and remove the extra A's. Thanks.

Multiple Items Ina TEXTBOX
Hello there, is there any way where we can add items to a text box instead of a combo box... Currently I am retrieving a list of items say customer names into a combo box.. Instead of a combo box can we add multiple items into a text box....ANY SOLUTIONS ?????

Multiple Items On Same Invoice
Hello,

I am developing an order tracking system for an organisation which repairs printers, monitors and other computer parts. Each Invoice generated should have entered multiple items like printers, monitors or others on it. How do i proceed ? I mean what controls in vb should i use so that multiple items can be choosen for same invoice id ?

Can anybody help me ? Please....

Ashish Kamat

Add Items To Multiple Forms
Hello,

I have two forms with comboboxes. These comboboxes have the same items. Is there an easy way to fill these comboboxes with a single routine?

I now fill the two comboboxes with two seperate routines

Sub FillNewUserForm
frmNewUser.cmbLocation.AddItem "Amsterdam"
frmNewUser.cmbLocation.AddItem "Utrecht"
frmNewUser.cmbLocation.AddItem "Rotterdam"
End Sub

Sub FillChangeUserForm
frmChangeUser.cmbLocation.AddItem "Amsterdam"
frmChangeUser.cmbLocation.AddItem "Utrecht"
frmChangeUser.cmbLocation.AddItem "Rotterdam"
End Sub

How To Select Multiple Items From A List Box To Another?
Hi guys..

I'd like to know how to select multiple items from a main list box to another list box? I've enabled the select extended on the main list box? Also, how do i remove multiple?
Currently, I can only move one item at a time.

Thanks!!

Regards
Vivien

Add Items In Multiple Columns Of A Listbox
Does anyone know how to add items into 2 columns of a listbox?
I have 2 columns but when I do this:
lstTopic.AddItem rs.Fields(0)
the value is added into the first column. How do i add an other value in the second column?
Thanks!!

Remove Multiple Items From A Listbox
How can I remove multiple items from a listbox?

I have tried this, but it won't work....


Code:
Dim i As Integer

For i = 0 To Me.lstFiles.ListCount - 1
If Me.lstFiles.Selected(i) = True Then
Me.lstFiles.RemoveItem Me.lstFiles.List(i)
End If
Next i

Remove Multiple Items From Listbox
Hi,

I have a listbox which is multiple selection enabled and I have a button which removes all selected items by looping through like so:


Code:
Do While PlayList.SelectedIndex <> -1
PlayList.Items.RemoveAt(PlayList.SelectedIndex)
Loop
This works, the problem is I have another piece of code which is triggered by the selected index being changed. It checks the count of the listbox and if empty does one thing and if not does another.

The problem is the selected index changes before the item is removed which means that even when the list is empty the count shows one and the program takes the wrong path.

Can anyone help?

Thanks
Stephen Reid

Listbox And Remove Multiple Items
i have this code for loading and removing items from a list box. i am generating an error with my remove item statment. i want to add the item at position i to the correct list box and also delete the item at postion i from both boxes. how i generate an invalid procedure call a the first removeitem command in either statement.

dim x as interger
x = 4

If card1Value > card2Value Then
MsgBox "card1 bigger " & card1 & " " & card2
For I = 0 To X
MsgBox I
lstDeck1.AddItem lstDeck1.List(I)
lstDeck1.RemoveItem lstDeck1.List(I)
lstDeck1.AddItem lstDeck2.List(I)
lstDeck2.RemoveItem lstDeck2.List(I)

Next
Else
MsgBox "card2 bigger" & card1 & " " & card2
For I = 0 To X
MsgBox I
lstDeck2.AddItem lstDeck1.List(I)
lstDeck1.RemoveItem lstDeck1.List(I)
lstDeck2.AddItem lstDeck2.List(I)
lstDeck2.RemoveItem lstDeck2.List(I)
Next I


any thoughts?

Adding Multiple Items Into A Listbox At Once
I am trying to access records from a database that is being created as the user enters data into the program. When they load the next form after entering the information, the data they entered is supposed to come up in a picturebox, with a few added items. The requirements of the assignment are that it has to print to a picturebox, but I can't get more than one record to print at a time. This is a program where names of students and their grades are entered, then on the next form, it is supposed to display all of their grades, both numeric and letter in a picturebox. I am successful in getting one piece of data to print to a picturebox, and I can also get it to print to a listbox or textbox, but never more than one piece of data. Is there anything I can do to get it to print out all the records from 2 columns of my database? I am trying to send the data to a listbox, then I am sending that to a textbox, then I am finally printing what's in the textbox.

Here is my code.

Private Sub Form_Load()
Dim i As Long
Dim str As String
index = 0

Set dbCon = New ADODB.Connection 'sets connection
dbCon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + _
"Data Source=grades.mdb"
dbCon.Mode = adModeReadWrite
dbCon.CursorLocation = adUseClient
dbCon.Open

Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset

addGrade = "SELECT numbers FROM Store ORDER BY Numbers DESC"
rs.Open addGrade, dbCon, _
adOpenForwardOnly, adLockReadOnly, _
adCmdText


With rs
Do While Not .EOF
list1.listitems.add(index + 1, , !numbers)
str = !numbers
Text1 = str & Text1
.MoveNext
Loop
.Close
End With


' List1.AddItem rs("numbers")
' Text1 = rs("numbers")
' rs.MoveNext

' picGrades.Print rs("numbers") 'prints text to picturebox
'rs.Close


'Centers the form
frmStudents.Top = (Screen.Height - frmResults.Height) / 2
frmStudents.Left = (Screen.Width - frmResults.Width) / 2
End Sub

I am getting a syntax error with this line of code:
list1.listitems.add(index + 1, , !numbers)
I used that because someone else on this forum gave me the code, but I do not know enough about VB to know what is wrong with the code.

Thanks for any help!

A Click Event For Multiple Items?
Hi, I'm using VB6.

I was wondering, can you make an event for when you click anything?

Because what I'm trying to do is, if you click [a-i][1-8] (a5 g3 etc), then it does

Code:
if a1.visible = true and b2.visible = true etc then
'something
end if

Because it would be a lot easier to put it all in one if than put it in 81 different if's

And it doesn't necessarily need to be clicking on an image, clicking anything would be good enough.

Thanks,
MountainDew7

Select Multiple Items In List Box
hi i got a listbox property , and i want it when i run the program , i can select multiple item in that listbox, however its wrong because it said cannot assign to read only property, --> listbox.multiselect = true is there anything code wrong? do you have solution how to fix this error so i can select multiple items in list box

thanks

Multiple Forms, Listbox Items
I have 2 forms.

When I add something to the listbox in the 2nd form and press the close button and reload it from a button on the 1st form, the items in the listbox are gone.

Is there a way to make the items stay?

Select Multiple Items In ListBox!
A VB6 Form has 2 ListBoxes which are populated from 2 different text files. Some of the items in the 2 ListBoxes are the same i.e. such items exist in both the ListBoxes. Note that the MultiSelect property of both the ListBoxes are set to 2 - Extended. The 2 ListBoxes are named List1 & List2.

When an item is selected in List1, I want that item, if it exists in List2, to get selected automatically in List2. This is how I have done it (Thanks to Hack for his input):
VB Code:
Private Sub List1_Click()    Dim strItem As String    Dim i As Long    Dim j As Long     strItem = List1.List(List1.ListIndex)     For i = 0 To List2.ListCount - 1        If List2.List(i) = strItem Then            List2.Selected(i) = True            Exit For        Else            For j = 0 To List2.ListCount - 1                List2.Selected(j) = False            Next        End If    NextEnd Sub
The problem is when more than 1 item is selected in List1. When I select Item1 in List1 & assuming that Item1 exists in List2 as well, then Item1 gets selected in List2 - till this point, no problem but keeping Item1 selected in List1, when I next select Item2 in List1 & assuming that Item2 exists in List2, then Item2 does get selected in List2 but Item1 in List2 gets de-selected whereas I want that since both Item1 & Item2 are selected in List1, both these items should automatically get selected in List2 as well. If either Item1 or Item2 (or both) are de-selected in List1, then these 2 items in List2 should also get de-selected accordingly.

In other words, what I want is when items are selected/de-selected in List1, if those items exist in List2, then those items should automatically get selected/de-selected accordingly.

What changes are needed in the above code to implement this?

How To Have Multiple Items In One Activex Control?
I want to have 2 controls in one activex .ocx file. When added to a VB project, there will be 2 icons added to the left. How do you have more than one?

Thanks!

Filter Recordset For Multiple Items
I have a recordset with events in it. There is an ID field to identify each record. The datatype is int. I want to filter this recordset for a string of values, eg: "1,2,3,4,5". Does anyone know how to do this with the filter property of the recordset?

Thanling you in advance
PORRASTAR

Selecting Multiple Items In A Listbox
Hey everybody!

I've got a listbox question:

Is it possible, to do this..

I've set a listbox to 'multiselect - 2. extended', which lets me highlight multiple entries.

I want to be able to click a button and then list all of the selected entries through msgboxes..

So, if I had this:

number 1 - selected
number 2
number 3 - selected
number 4
number 5 - selected

and I hit the button, I would get three message boxes pop up, with "number 1", "number 2", and finally, "number 3" in them

Thanks to anybody that answers this

Selecting Multiple Items In Listbox
Hi All,

I have a list box which is populated from an array in the following manner


VB Code:
For lintCtr = 0 To UBound(ClinicArray, 2)  '1 for Clinic name  ClinicList.AddItem ClinicArray(1, lintCtr)  '0 for Clinic id  ClinicList.ItemData(lintCtr) = CInt(ClinicArray(0, lintCtr))Next


Now what I need to do is when I load my new form that it checks in the database for which clinics someone belongs to and then automatically selects them.

For example one person is connected to 2 clinics, clinicid 2 and clinicid 9

These integers match the integers populated in the ItemData options.

How would I go about using the ClinicList.Selected(???) = TRUE?

I have the following but it fails if the clinicid is greater than 9??


VB Code:
Do While Not RS.EOF     ClinicList.Selected(ClinicList.ItemData(RS("cu_ClinicID"))) = True     RS.MoveNextLoop

Retreiving Multiple ListBox Items
Any suggestions on how to check for multiple selected items in a ListBox and pass each value to a MAPI control.

I have no problem picking one item and this being passed correctly, but I'm having problems with multiple selection of items. I have been fighting with a For-Next loop trying to test each value as selected or not. Any sample code would be much appreciated.

Sincerely,

Multiple Items From Access To PowerPoint
I have a line of code that I have downloaded from the web to allow me to transfer info. from microsoft acces to power point however I need to alter it to transfer more than one item and place it in specific place on the slides or even on a table. However I dont know anything about VBA so I was looking to see if anyone could give me some help with how I add oher fields in this code and how I would place the items in different places or how to use this code or another one if you know of one to allow me to put items n a table from there i can figure out the rest. Here is the code. thanks in advance.


Option Compare Database

Option Explicit


Sub cmdPowerPoint_Click()
Dim db As Database, rs As Recordset
Dim ppObj As PowerPoint.Application
Dim ppPres As PowerPoint.Presentation

On Error GoTo err_cmdOLEPowerPoint

' Open up a recordset on the Employees table.
Set db = CurrentDb
Set rs = db.OpenRecordset("qryOpenJobLog", dbOpenDynaset)

' Open up an instance of Powerpoint.
Set ppObj = New PowerPoint.Application
Set ppPres = ppObj.Presentations.Add

' Setup the set of slides and populate them with data from the
' set of records.
With ppPres
While Not rs.EOF
With .Slides.Add(rs.AbsolutePosition + 1, ppLayoutTitle)
.Shapes(1).TextFrame.TextRange.Text = "37 COMM SQUADRON"
.SlideShowTransition.EntryEffect = ppEffectFade
With .Shapes(2).TextFrame.TextRange
.Text = CStr(rs.Fields("JCN").Value)
.Characters.Font.Color.RGB = RGB(255, 0, 255)
.Characters.Font.Shadow = True
End With
With .Shapes(3).TextFrame.TextRange
.Text = CStr(rs.Fields("EQ ID").Value)
.Characters.Font.Color.RGB = RGB(255, 0, 255)
.Characters.Font.Shadow = True
End With
.Shapes(1).TextFrame.TextRange.Characters.Font.Siz e = 50
End With
rs.MoveNext
Wend
End With
' Run the show.
ppPres.SlideShowSettings.Run

Exit Sub

err_cmdOLEPowerPoint:
MsgBox Err.Number & " " & Err.Description
End Sub

Please Help Me With Drag-n-Drop Of Multiple Items
Hello!

I'm facing a problem with Listview Drog and Drop of multiple items from one listview to another listview. When I try to Drag only one single item, the item is dragged without any problem. However, when the multiple selected items are dragged, the Listview on which the items are dropped, receives information about only one item and not all selected items. The item, about which the information is received, is the same on which I click and hold mouse to start drag action. So, it looks like even though multiple items are selected in a listview, while executing the Drag-Drop action, listview treats it as single item selected!

Is this a default behavior of Listview or am I missing/doing anything wrong? Any work-around for this (seems like default) behavior of Listview? I searched for it and got a code example at http://btmtz.mvps.org/listview/ where the author has demonstrated Drag-Drop of multiple items. However, the code is specifically restricted to re-arranging items within same Listview and the information is transported via Drag-Drop to another Listview, upon which the items are dropped.

Waiting for your valuable reply ...

Regards,

Ruturaj.

If Statement To Apply For Multiple Items
Code: If frmBlah.cmdButton.Text = "Value Then
        Counter = Counter - 1
        frmeasy.txtCredit = intCredit
      EndIf
        


ok simply an if statement , but what i want to do is something like

If frmblah.cmdbutton.text or FrmGah.cmdbutton.text = Value Then

you know what i mean? make the If statement apply for multiple command buttons in this case
Of course i could probably use NESTED IF statements but is it possible to put it all in one line?

Copyright © 2005-08 www.BigResource.com, All rights reserved