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




Moving Collection Items


I've never used a Collection before and I was wondering how would I go about moving an item from one index to another?

I want to display the item that has an index of 0 and then remove it form the collection at a certain interval. Then I want to move all teh other items up a spot in the collection. (1 becomes 0, 2 becomes 1, etc.)

Thanks in advance.

Edit: Also, is there a fast way to clear a collection other than looping through it all and setting the values to null?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
How To Get Certain Items Of A Collection
I developed an application which stores two types of objects as items of a collection. theBlockCollection which consists of a collection of pictures and theLineCollection consisting a collection of lines. There are additional properties in each of the objects as shown in the attached pictures (collectionofpicitem1.jpg and collectionoflineitem.jpg).
In this application I can draw a rectangle at runtime (shown in the attached picture: collectionofpicitem.jpg). I need to know if I want to dynamically load a 2D array the contents of collectionoflineitem.jpg but only those that are enclosed within the rectangle, how can I do that?

256 Max Items In A VB Collection?!
Where is this documented!?!? This is the first time that I have had collections that needed this much data, and now I find out I can't do it! Worst of all, there isn't even a VB runtime error generated when you try to go over it, it just doesn't add anymore items. Can someone please tell where I can find it documented from Microsoft that it is true, in fact, that you can only have 256 Items in a collection...

Items In A Collection
To referance an item in a collection this is what I do

Dim XItem

For Each XItem In colCountries
.........
next


Is there any way to referance the item , without declaring XItem as a variant ?

Key For Items In A Collection
Hi,

I have a problem.
Removing an item from a collection, and then adding a new object with a Key like the one of the deleted item, I get a message "This key is already associated with an element in this collection (error 457)".
What can I do to be able to reuse the deleted key ?

Help ! Before I go mad !

Thanks !

Oren.

Gettting Items Out Of A Collection
Well after much searching and much reading I finally was able to implement my collection class. However I have a problem in that I can't get items out of it. I've looked at several Tutorials and did what they did to get items out but it doesn't work for me. If someone could give me some help on this I would appreciate it. Now I use the same method for storing items in my collection so what works for one should work for all. How it goes is that in the forms Load event I call a ClassHandler Sub which is housed Inside my GeneralInfo Module and will handle the various things needed to set the information I need in various places in the game. I store the routines by reading a text document so I have another Module Called TextReader which contains all code to store all Collection Classes. All of my routines that store my Collection Classes Start with Initialize and end With the name of the class. For example InitializeItem handles items, InitializeMonster handles Monsters, and so on. In the decleration section of the GeneralInfo module I create a new instance of the collection and class.

-----All this is in the declerations section of The GeneralInfo Module-----
Public MasterMonsters As Monsters
Public MasterItems As Items
Public MasterRaces As Races
Public MasterItem As Item
Public MasterMonster As Monster
----------------------

-------This is in the declerations section of the TextReader Module
Dim LeftBracket As Integer
Dim RightBracket As Integer
Dim Temp As String
Const ItemNumber As Integer = 8
Const MonstNumber As Integer = 4
Const RaceNumber As Integer = 1
Public TextCounter As Integer
---------------------------------------

Now I set the Collections and Classes in the Subs that read a them

--Each of these pairs are included in the Intialize event which reads their respective collection classes----------------

Set MasterItems = New Items
Set MasterItem = New Item

Set MasterMonsters = New Monsters
Set MasterMonster = New Monster

Set MasterRaces = New Races
Set MasterRace = New Race
--------------------------------------------

Now the TextHandler reads the Initialization subs in the order of Item, Monster, Race.

In the text file the information for each property of the class is closed in brackets to allow me to take out only the information I want. Each field is labeled in the text document to insure I don't change the wrong thing or add things in the wrong order(only when typing up the text file).

-------This is the InitializeItem Event---------
ItemPath = App.Path & "CollectionClassText.txt"
Open ItemPath For Input As #1
Line Input #1, Temp

Do Until TextCounter = ItemNumber
Line Input #1, Temp
LeftBracket = InStr(Temp, "[") + 1
RightBracket = (InStr(Temp, "]")) - LeftBracket
MasterItem.Key = Mid$(Temp, LeftBracket, RightBracket)
Line Input #1, Temp
LeftBracket = InStr(Temp, "[") + 1
RightBracket = (InStr(Temp, "]")) - LeftBracket
MasterItem.TypeofItem = Mid$(Temp, LeftBracket, RightBracket)
Line Input #1, Temp
LeftBracket = InStr(Temp, "[") + 1
RightBracket = (InStr(Temp, "]")) - LeftBracket
MasterItem.Weight = CInt(Mid$(Temp, LeftBracket, RightBracket))
......................
......................
TextCounter = TextCounter + 1
MasterItems.Add MasterItem, MasterItem.Key
Loop
--------------------------------------------------

I didn't include all of it because it is pretty much all the same thing with the difference that each reads a different field. As you can see ItemPath is set to the location of the text file which is opened with that string. The loop counter is used in all other procedures and always set to 0 at the beginning. I declare a constant for each class collections number of entrys. I'll change this constant as I add more. I seperate out the brackets with the InStr function. One for the left bracket and one for the right bracket and then use the Mid$ function to return the string between the brackets. Whenever the Field is a string I enclose the Mid$ function inside the conversion function. The textcounter is updated at the end and then I pass the class I Instanced earlier to the collection I instanced earlier. This allows me to skip declaring as many variables and makes it look neater. I don't know if this could be the problem with getting the information out. All the other Initialize routines do about the same thing with the exception of using their respective Collection and class. I also put a header in the text document before each different type of information. So in each other routine after this one I'll Use the Line Input before the loop to bump down the current line so no errors will be generated. Now I don't have a problem with storing at as I said earlier but I figured this would help let you know what I'm doing and if there was a problem in here that causes the problem with retrieving the information.

---------Declation in the GeneralInfo Module----------------
Public Type CharInfo
BaseHP As Integer
CurHP As Integer
BaseMP As Integer
CurMP As Integer
BaseDV As Integer
CurDV As Integer
BasePV As Integer
CurPV As Integer
BaseLuck As Integer
CurLuck As Integer
BaseDex As Integer
CurDex As Integer
BaseIntel As Integer
CurIntel As Integer
BaseMD As Integer
CurMD As Integer
BaseStr As Integer
CurStr As Integer
End Type

Public TempRaceA s Race
Public TempRaces As Races
--------------------------------------------------

-------Code in the Stats Sub------------
Dim CurChar As CharInfo
Set TempRace = New Race
Set MasterRaces = Races
Set TempRaces = New Races
Set TempRaces = MasterRaces
Set TempRaces = TempRaces.Item(1)
TempRace = MasterRaces.Item(1)
------------------------------------

The Declerations Creates A UDT to hold the characters stats. After that the Stats Routine is suppose to pull a Race out of the Races Collection and then I'll use that to fill in the Stats. This code up top started by looking at thinkers Tutorial and trying to use what he did to serve my purpose. However his method didn't work and I've tried every combination I can think of in the Stats Sub but nothing works. I've got two basic responses. It either runs through it but The collections are nothing or it gives me a runtime error "Object variable or With Block Variable not set". I've tried taking out set statements and putting them in and everything I can think of even if it didn't make sense due to running out of trying things that did make sense. I would very much appreciate help sense this is the last part of Collection classes that i have to understand.

Counting Items In Collection
Hi,
I want to execute what should be a simple task, namly to count the number of items in a collection (a collection of custom document properties in Word) but i can't find any information on msdn on how to do that. Can anyone help me?
Thanks a lot in that case.

Sorting Items In A Collection
Do you have any idea how I might sort a user defined collection. For example, I created my own class with certain properties that I would like to put in alphabetical or sequential order. I would rather not write the collection to a spreadsheet for sorting. Thought about writing my own sort routine but it might get a bit lengthy. Does excel possibly have anything built in?

Add Filtered Items To A Collection
Hello-

I am using John Walkenbach's code to add unique items to a list box. However, I want to go a step further so that when someone selects from one listbox, it filters the table where the data comes from and then populates a second listbox with the filtered unique items from a second column. Here is the portion of his code:


Code:
Set AllCells = Sheets("PART Table").Range(Cells(2, 2), Cells(Range("a65536").End(xlUp).Row, 2))

On Error Resume Next
For Each Cell In AllCells
'If Cell.SpecialCells(xlCellTypeVisible) Then
NoDupes.Add Cell.Value, CStr(Cell.Value)
' Note: the 2nd argument (key) for the Add method must be a string
'End If
Next Cell

As you can see, I was trying to do something with the SpecialCells property, but I don't quite understand how to do it. I thought the two options might be to either set the range to somehow only include visible cells, or as I was trying here, only add them to the collection if the cell was visible.

Any help would be appreciated.

Thanks!

Sorting Items In A Collection
I have a multidimensional array and I need the unique values from one column and I need them sorted. I am able to do this with text but when it comes to numbers it doesn't work. Once I get the unique values and they are sorted I add them to a combo box. How can I sort these unique values easily? Isn't there a way to sort a collection?

Here is some code:


Code:
On Error Resume Next
For i = 1 To UBound(fgarraydata, 2)
col.Add fgarraydata(grdColumnNames.col, i), fgarraydata(grdColumnNames.col, i)
Next

For i = 1 To col.count
cmbColumn(0).AddItem col.Item(i)
Next

Removing Items From A Collection??
I want to remove an item from my collection and It keeps bombing out. Can someone take a look at this.
I want to remove the first record in my collection

'heres my form*******
'this is my remove
Private Sub cmdremove_Click()

mproducts.remove ("1")

End Sub

' this is how I add the product***********
Private Sub cmdsave_Click()


product.productid = txtproductid.Text
product.productname = txtproductname.Text
product.productcost = txtcost.Text
product.productprice = txtprice.Text
product.unitsinstock = txtunits.Text
mproducts.add product

Set myproduct = mproducts.item("1")
cmdsave.Visible = False
cmdadd.Visible = True
cmdremove.Visible = True
cmdbuy.Visible = True
'outputs the productid fine*******************
MsgBox myproduct.productid
MsgBox mproducts.count


'Here's my collection***********************************

Private mproducts As Collection

Private Sub Class_Initialize()
Set mproducts = New Collection
End Sub

Private Function NextProductCode() As String
Static intCode As Integer
intCode = intCode + 1
NextProductCode = Trim(Str(intCode))
End Function

Public Sub add(prod As CProduct)
mproducts.add prod, NextProductCode

End Sub

Public Sub remove(ByVal strkey As String)
mproducts.remove strkey
End Sub

Public Function item(ByVal strkey As String)
Set item = mproducts.item(strkey)
End Function

Modifying Items In A Collection
What i'd like to do is change the value of an item in a collection, but i keep on getting an "object required" error.

If i've got a collection say:

Dim args As New Collection
dim backupvar as string

args.add (var1)
args.add (var2)
args.add (var3)
args.add (var4)

For n = 1 To args.Count
if len(args.item(n)) > 20 then
args.item(n) = backupvar
endif
Next

Is there a way to do this?

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

Maximum Items In A Collection
I got a problem with the collection object in Visual Basic 6.

A maximum of 256 items can be added in a collection. But, if you pass this limit, no more item are add in collection, but the count property continue to expand.

Example:

Dim colTest As New Collection
Dim iCpt As integer

For iCpt = 1 To 300
colTest.Add iCpt
Next

The collection contents 256 items, but the count property is 300.

Why?

Clear Collection Items ....,
Hai ,

I have a new collection RowE , i keep adding values to the collection and perform some string comparision, addition or whatever with them all, Now when i unload the form i need to clear all the contents in the collection .

That is i want, RowE.Count shld be = 0.

How can this be done.....,

Any comments/codes/ideas highly appreciated...,

ashky

Removing Items From A Collection
Can anyone give me any examples of how they would remove several items from a collection without getting a "subscript out of range " error.

I have a collection of maybe 60 items and most of them due to validation will be removed leaving me with around twenty, the thing is once I have removed about 30, I get the above error.

I am presuming this is because the key to each item is reassigned when you remove an item.

I have tried restarting my for each loop each time I delete an item but this doesn't seem to make any difference

Max No Items Can Be Added To A Collection?
After reading the help files and searching through a couple of text books, I could not find the max number if items that can be added to a collection. I have a feeling it is 256, is this correct?????

Cannot Modify Items In Collection (VB.NET)
I am running into a strange error when I try debugging my current application. A form loads up with a dynamically-populated textbox full of software titles. Upon selection of a software title and pressing 'GO' a checkboxlist is displayed with the users who use the current software. The checkboxlist is bound to a dataset named "DataTable" and has the DisplayMember set to "Employee" and the DataValue set to "ID", like the following:


Code:


Dim strSoftwareTitle As String = comboSoftwareTitles.Text()

Dim objConn As New OleDb.OleDbConnection
objConn.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings("strConnection")

Dim strSQL As String = "SELECT ID, EmployeeName FROM tblSoftware WHERE " & _
"(SoftwareTitle = '" & strSoftwareTitle & "') AND " & _
"(EmployeeName Is Not Null) ORDER BY EmployeeName ASC;"

Dim ds As New DataSet
Dim objCommand As New OleDb.OleDbCommand(strSQL, objConn)
Dim myCommand As New OleDb.OleDbDataAdapter(strSQL, objConn)

myCommand.Fill(ds, "DataTable")

Me.clBox.DataSource = ds.Tables("DataTable")
Me.clBox.MultiColumn = False
Me.clBox.DisplayMember = "EmployeeName"
Me.clBox.ValueMember = "ID"



When I run the application the first software title in the list happens to be "Adobe Acrobat 6.01 Professional." When I hit 'go' I get the error below:


Code:


Additional information: Cannot modify the Items collection
when the DataSource property is set.



The line that is highlighted in debug mode is the following:


Code:


Me.clBox.ValueMember = "ID"



If I quit and run the program again and scroll down and select "Visual .NET 2003 Enterprise" and press 'GO', the checkboxlist displays flawlessly. What could cause my application to error upon selection of the first selection, but not another one in the list. In the subroutine that errors I am not modifying the Items collection. If this isn't clear enough I can provide more information.

Any suggestions?

?collection - Order Of Items
Hello,

I have this problem of getting the exact/original order of fields from a table.

For example:
  Student Table:
    Fields:
      student_id
      first_name
      last_name
      initial
      birthday


Above is the exact order of the fields from student table. When I retrieve this info using Adox.Catalog, it is sorted alphabetically. So what I get is birthday,first_name,initial,last_name,student_id. But I don't want this. I want it sorted the way it is on my table definition. Is there a way that will not sort this info? After getting the field info, I add it to a collection.

Thanks you!

Maximum Items In A Collection
Hi Guys,

Just out of curiosity, what is the maximum no. of items in a collection? Or how many items can a collection can store? I tried google already but I can't find any answer from there.

Also, is it possible to limit the usage of memory my own program? If possible, pls. tell me how to do it.

TIA!

Changing Items In A Collection
I have a collection where I store Data from a database. I then parse the collection into an array and then put the array in a listview with a function that is in a dll that is used.
 
In this collection i store the screens and the access permissions for those screens for a specific group.

For example the output to a list view for the administrator would be

Job Maintainence        Full Access
Scheduling            Full Access

If i wanted to parse the collection into an array how could i then change a "full accesss" to a "read Only access" or "No Access" When the user clicks the appropriate button?

Linking Items In Listbox With Collection
In my program I have a collection class and a listbox. The items in the collection class have a string value (a name if you like, which can be the same for multiple items in the collection) and a unique identification number (never the same for more than one item). Because the number is always unique I’m using this as the Key for each item in the collection.

I’m using the listbox to display each item in the collection so the user can click the list to bring up all the stored properties of the clicked item. However I need to display the string value of each collection item in the list, as displaying the unique id number would not be very useful to the user. As I said the string can be the same for different items, so what I need to know is how to link together the items in the listbox with the items in the collection.

At the moment I’m using the fact that the index property of an item in the listbox is 1 less than the index of the item in the collection (since the collection runs from 1 to max and the list runs from 0 to max). This is a little restrictive however, for instance if I wanted to rearrange the items in the listbox, to sort them alphabetically, the indexes would change and I wouldn’t be able to link the listbox items to the collection items. Unfortunately the listbox control doesn’t seem to let you specify a key for each item added to it or I would just use the unique ID as the key for this too, then you could link them.

Is there a way to solve this problem? Or am I going to have to look at using a different control than the listbox.

Displaying Items From Collection In A Listbox
how is it possible to display all items in my collection in a listbox
here is my code

Dim Employees As New Collection


Private Sub Form_Load()
Employees.Add 5400, "Neville Kalebi"
Employees.Add 3300, "Andrew Denousse"
Employees.Add 3300, "Dean Delcy"
Employees.Add 3500, "Mervin Albert"
For Each Employees.Count In Employees
lstCollection.AddItem Employees.Count
Next
appreciate the help
thks

Maximum Collection Object Items
Hello

I am interested if anyone knows the maximum number of items that can be held be one collection object.

Any help would be appreciated.

Kevin

Deleting Duplicate Items From Collection?
how to delete or find out duplicate items from a collection. i mean looking for a fast alogorithm which can do this.. or do you know how to catch the error when a duplicate key is added to a collection?

Sorting MS Outlook's Folder.Items Collection
I’d like to sort mail items from an Outlook folder before I populate a grid,
So, I’ve invoked the Sort method of Items collection of that folder:

oFolder.Items.Sort "ReceivedTime", True

(The result should have been a descending list of mail items sorted by ReceivedTime property)
But here’s the actual result (just Received times):
18.04.2003 22:03:29
15.07.2003 10:03:31
18.07.2003 12:42:46
25.07.2003 17:23:12
17.07.2003 10:34:01
20.07.2003 15:17:47
28.07.2003 16:59:54
01.08.2003 13:00:59
25.08.2003 10:45:08
29.08.2003 10:25:15
03.09.2003 13:43:34
09.09.2003 11:41:14

Only month order is correct but it’s ascending!
What went wrong? Any ideas?

Need To Identify Connectivity Among A Set Of Items In A Collection Object
I need some help
I have a collection object mCol whose items consists of the following in which sFrom and sTo are string while index is an integer. In this example the mCol consists of 6 items but it can be more (or less). The input for this problem is starting and ending point. For example the input for the example below is id1 and id6.
sFrom sTo Index
item1: id1 id2 1
item2: id1 id3 2
item3: id1 id4 3
item4: id2 id5 4
item5: id4 id5 5
item6: id5 id6 6

I need to find the number of ways id1 is connected to id6, i.e. the output will be displayed as follows:
id1 id2 id5 id6
id1 id3 id5 id6
id1 id4 id5 id6
The output will be stored in a variable dynamic two dimensional array. Can anyone suggest me a good approach? Please note that the approach have to general and should work for any starting and ending point given a certain set of items.

3265 Items Cannot Be Found In Collection - Sometimes Works?
Stumped on this one. I keep getting the 3265 error "Item cannot be found in the collection".


What is weird is that all my other executions of the stored proc work except for this one.



cn.Open "Provider=sqloledb;Data Source=LAPTOP;Initial Catalog=Production;User Id=sa;Password=sa;"

' Get the next key
SQL = "spGetNextKey('grp')"
Trace (SQL)
Rs.CursorType = adOpenKeyset
Rs.LockType = adLockOptimistic
Rs.Open SQL, cn, , , adCmdStoredProc
grpId = Rs("keyId")
Rs.Close

it bombs on the grpdId = rs("keyId") line. 3265 item cannot be found in the collection

the weird thing is that if I execute this code:

' Load the group type combo
SQL = "spGetType(12)"
Set Rs = cn.Execute(SQL)
frmMain.lstgrpType.Clear
Do While Not Rs.EOF
frmMain.lstgrpType.AddItem Rs("typTypeDesc")
frmMain.lstgrpType.ItemData(frmMain.lstgrpType.NewIndex) = Rs("typTypeId")
Rs.MoveNext
Loop
Rs.Close


it works fine.

The only difference is that the second (the one that works) returns values right from the table itself.
But the first (the one that does not work) calcs a value then returns it.

I'm finding bits and pieces about CAT? on the net but not sure what it does or if it'll help.


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

Update... I got it to work by first returning the table value, then updated my next count, blah, blah.

Anyways it has got something to do with this 'catalog' value in ADO.. what does it do? WIll I be able to create stored procs that do strict calculations (no table stuff) and get the value back?

Easy (???) Swap Items In A Collection Question
Hi there, I have this ridiculous problem that I just can,t resolve!

I have a collection, and I wish to swap two elements. I tried this:


Code:
Set pCol.Item(lngFirst) = pCol.Item(lngLast)

but it just won't work.

How should I do this?

Find Method Of Items MAPIFolder Collection
hi all...

i'm trying to open an Outlook email using the Find method of Items collection from an Outlook.MAPIFolder


VB Code:
Set oApp = New Outlook.Application    Set oNS = oApp.GetNamespace("MAPI")    Set oInbox = oNS.GetDefaultFolder(olFolderInbox)        strFilter = "[EntryID] = '00000000A11992B52436EE47A7D2CD13200DE9910700B36B58C5B04BD511A1DA00E018C46C90000000543FCC0000B46B58C5B04BD511A1DA00E018C46C900000027A05100000'"    Set myItem = oInbox.Items.Find(strFilter)    myItem.Display


but vb sends me the following error :

The property "EntryID" in the condition is not valid.

when removing the single quotes ( ' )


VB Code:
strFilter = "[EntryID] = 00000000A11992B52436EE47A7D2CD13200DE9910700B36B58C5B04BD511A1DA00E018C46C90000000543FCC0000B46B58C5B04BD511A1DA00E018C46C900000027A05100000"


the error is :

Unable to parse condition.Error at A11992B52436EE47A7D2CD13200DE9910700B36B58C5B04BD511A1DA00E018C46C90000000543FCC0000B46B58C5B04BD511 A1DA00E018C46C900000027A05100000.


pls note that when using
[Subject] field in search criteria (e.g. strFilter = "[Subject] = 'Info'" )
works great ...

what am i doing wrong ? ... any help .?

How To Determine Whether All Items In Array Exist In Collection
A Have an array of Strings, and a collection of Strings.
I'm having a little trouble figuring this out. What I want to do is see if all the strings in my array exist in the collection.

Adding Items To A Collection, Properties Are Changing On The Fly
I have the following code in a module:
Code:Dim SearchTypes As New clsFindParams
Dim AllSearchTypes As New Collection

Sub InitSearchTypes()
    With SearchTypes
        .BaseText = "C"
        .NumLeftChars = 0
        .NumRightChars = 6
        .ReplString = "CXXXXXXXX"
    End With
    AllSearchTypes.Add Item:=SearchTypes, key:=SearchTypes.BaseText
    
    With SearchTypes
        .BaseText = ".txt"
        .NumLeftChars = 24
        .NumRightChars = 0
        .ReplString = "XXXXXXXX.TXT"
    End With
    AllSearchTypes.Add Item:=SearchTypes, key:=SearchTypes.BaseText
    
End Sub


and the following in a class (clsFindParams):
Code:Public NumLeftChars As Byte
Public NumRightChars As Byte
Public BaseText As String
Public ReplString As String


My objective is to make a collection of "SearchTypes". I find that after the first "ADD", there appears an item in AllSearchTypes with, in this case, the property "BaseText" = "C". As the next set of code executes, setting the values of "SearchTypes" to the next item's specifications, I can see the properties of the first item changing to these new values.

What do I have to do to add a NEW value (the second item in my code above) without the first item changing?

|
+--JDMils
|
+--VB6
+--VB Dot Net
|
+-- Navman GPS Forums @ http://forum.jdmils.com
|

Sorting MS Outlook's Folder.Items Collection
I’d like to sort mail items from an Outlook folder before I populate a grid,
So, I’ve invoked the Sort method of Items collection of that folder:
oFolder.Items.Sort "ReceivedTime", True
(The result should have been a descending list of mail items sorted by ReceivedTime property)
But here’s the actual result (just Received times):
18.04.2003 22:03:29
15.07.2003 10:03:31
18.07.2003 12:42:46
25.07.2003 17:23:12
17.07.2003 10:34:01
20.07.2003 15:17:47
28.07.2003 16:59:54
01.08.2003 13:00:59
25.08.2003 10:45:08
29.08.2003 10:25:15
03.09.2003 13:43:34
09.09.2003 11:41:14
 
Only month order is correct but it’s ascending!
What went wrong? Any ideas?

My Collection Object Is Repeating Its Items Like A Bad Burrito
The parts of my program that are relevant to my problem are: a ListView control and 2 Collection Objects. Collection one holds objects (weapons, specifically) created upon running the program. Collection two is the player's personal inventory of weapons and hold what is taken out of C1. The ListView displays the contents of C2.
As I'm testing the program, I use 2 different weapons (knife and gun), but the ListView displays 2 guns (the 2nd object created and transferred). With no desire to list all the code, here is a short idea of what I've done:

1. create knife and add it to C1
2. transfer knife from C1 to C2
3. remove knife from C1
4. create gun and add it to C1
5. transfer gun from C1 to C2
6. remove gun from C1
7. display C1's objects in ListView
(btw, I'm using a Colection as C1 because later in the program there will be more than 1 object at a time for the player to choose from)

Now, why is it that I'm seeing 2 guns listed in my ListView? When coding the display, I iterate through the objects in C2. Can someone help me? Either ask me for more detail if you need it or if there is a simpler way to handle this, just tell me. Thanks in advance for any help given.

Disabling Menu Items When Using Collection Array
I have a parent form with a menu, and I want some of the menu items disabled when a child form is opened. The book I am learning from only gives an example for unique named menu items, not arrays. Is there a way to disable one menu item when an array was used. Thank you in advance.

Catrina

VB 6.0/Outlook 2000 - Adding Items To A Pst File Collection
I am trying to add Outlook contact items to a pst file. I am using the Outlook object model. I have created a pst file programmatically using the AddStore method. This appears to create an empty file. I have a folder of Outlook contact items that I need to add/save/move to the pst file. I read a post here that says you need to walk thru the contact items collection and add them to the pst file items collection. Can anyone provide an example of how to do this?

I know how to loop thru the contact items but cannot find a method that adds items to the pst file

TIA

KT

Moving Through Items In A Listview
Am I being a complete , or what? I'm trying to move through the items in a listview, so that I can insert the entries one-by-one in to DB - ie each item in the listview represents a new record in a DB table.

Now, I would have expected (as with all things VB) this to be quite straight forward. Something along the lines:

ListView1.selecteditem.movenext

I know this a bit hopeful, but I can't believe there's no way to incrementally move through all the items.

I've been through MSDN and searched this entire forum for a similar thing but I cant find anything.

I must be missing something really obvious here!

Moving New Menu Items From One PC To Another..
Hi there. I'm using MS Word 2003 in my PC A. I'v built a new menu (e.g. Letter Template with 35 sub menu items (each item built with some macro scripts)) on the menu bar (at the right of "Help") and now I have to work with another PC B. How can I move the new menu items from PC A to PC B without having again to use the "Customise" to add all the menu items in PC B?

Cheers.

Moving Items Up And Down In A Listbox
I just solved this question that I've had for a while.

Thought I'd share the code.

http://cornempire.newezone.com/resou...e/listmove.htm

Moving Items To The End Of The List!
hi!all!
i am looking for a code to move a selected item to the end of the list box!

for example i have a list1 with items
1
2
3
i select the first item ,item 1 and then click the button!
the item should move to the end of the list and the list would look like>
2
3
1
---------------------------

Moving Menu Items
Hi folks, I found a post the other week concerning moving menu items up and down the list by clicking and dragging them to a different place (Like in IE's faves). I was wondering if anyone could find this post as I have spent the last 20 mins looking with no solution.

Any help would be much apreciated

Lucas

Moving Items In A Listbox
Hi, I have a listbox, with the following:

[case 1]
Msg "Hello"
[case2]
msg "hello"

You can place these items on another dialog.
but, I need it to look like:

[case1]
Msg "hello"
... ---->Open a new space for more Messages when you place one.
[case2]
Msg "hello 2"

This is the code I have so far, but it isnt working.


Code:
Private Sub Command1_Click()
Dim newe As Integer


newe = Newevent.EventList(Eventnum).ListCount
Newevent.EventList(Eventnum).AddItem "<Msg>: " & Text1.Text, newe
'This bit is OK, places the message.

If Newevent.EventList(Index).Text = "..." Then
Newevent.EventList(Index).List(Newevent.EventList(Index).ListIndex) = "..."
Newevent.EventList(Index).List(Newevent.EventList(Index).ListIndex) = "<Msg>: " & Text1.Text
'Only one thing to happen for a Case
'Need it so you can have more than 1 Message under
'case 1, case 2,etc... (Move every ListItem down 1?) -Chris

Dim Position
For n = Newevent.EventList(Index).ListCount To Position + 1 Step -1
Newevent.EventList(Index).List(n) = Newevent.EventList(Index).List(n - 1)
Next
Newevent.EventList(Index).List(Position) = "..."
End If
Exit Sub

Unload events
Unload Me

End Sub

Private Sub Command2_Click()
Unload Me
End Sub

Any help would be appreciated

Chris

Moving Items Together From Two Listboxes!
i have two lists!

list 1 list2

math sci
history soc
math sci
drawing fun
physics sci
biology sci
phys.eductaion fun

list1 has the subjects
list2 has the category of the subjects

now i can arrange the second list so that sci goes first then soc then fun
(i have the code for this) but the problem is that together with the category also the subject should move.

so i want them to move together when being sorted!
is there any way to keep them together!
i have done something with listindex and topindex but it is not functional for this case!

Moving Items Up And Down In A List Box...
Hey guys, I was wondering if anyone can help me on how to move items up and down a list box? Also, if I want to move an item start from the bottom to the top?

Please, help me...

Moving Items Around A List Box
hi !
I have yet another short query here..and would be grateful if anyone could help.
I got a list box with a playlist for a radio show..and to the right of it i have 2 more listboxes..one with duration of track and the other with the point in time at which the track starts in the show.
I have 2 buttons below up and down which when clicked on move the selected item up or down in the playlist accordingly along with the related times.
How do i do this ?
Also how do make sure that there is one item selected at aLL times.
any help would be great !

Harpooon

Moving Items In Listbox
im trying to get items in a list box to move up and down im not sure how to do it i dont have the first clue wot to do can anyone help with the code?

Moving Items In An Array
G'day

I have a numeric array (20,7).

The user is allowed to delete one line (1 to 20).

If the used deletes line 7, I need to move all items 8 to 20 down 1 and zero number 20 so I don't have a blank line in position 7

Is there an easier way to do it rather than a for/next loop

Peter.

Moving Items Between Listboxes
Hey...

Could someone please provide me with the syntax for moving items in between two listboxes (i.e. List1 and List2)?

I'm having some trouble fiddling about with it. I simple want to be able to add items from List1 to List2 (deleting the item from List1 in the process) and vice versa.

Thanking you in advance...

Moving ListBox Items
Could anyone tell me how to write a sub that allows you to click and drag an item in a listbox to a new index position within the listbox?

Ash

Moving Items In A Listbox
I have a listbox that has several items in it that i want the user to be able to move up or move down. I have two buttons, one for up the other one for down. Anyone know how to do this? Thanks!

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