Copying A Listview Object? (More Generally, Copying Any Object To Another)
Hey all. My searches didn't really clear anything up for me, so I thought I'd ask my question specifically:
I have a form with a listview the user can populate. Once done, they can clear it. I need to have a recall feature that would allow them to basically undo the clear. My initial thought is to copy the form's listview to a listview object declared dynamically. However, this statement I think just creates a reference to the forms listview: Set DynamicListView = FormListView. So, when I clear the FormListView, of course the DynamicListView clears too, since its just pointing to the same view.
How do I dynamically create one listview from one on the form?
Thanks!
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Object Copying
Suppose you have an object, which has multiple properties, objects, etc in it. How do you make a copy of it ? (ByVal that is ...)
Thx,
<font color=green>Do or do not
There is no try</font color=green>
Copying An Object
I have an object myObj1 of some type myObj. I want to make a copy of myObj1 so I use this code:
Code:
Dim myObj2 As myObj
Set myObj2 = MyObj1
Now, if I modify myObj2 it turns out that myObj1 undergoes the same modification. In other words, the code above is not creating an independent copy of myObj1, rather it's creating a second name for the same object. Does that make sense?
Copying An Object...
Hello,
Looking for a quick and easy way to COPY an object as opposed to creating a reference.
I'm under the impression that
Code:
Dim B as New MyClass
Set B = A
Will create a reference, and changes to object A will change object B, right? I don't want that, I want a brand-new copy of the object.
Thanks!
--Ben
Copying An Object
Hi,
I have a very simple question. How do you copy an object? And I'm not talking about creating another reference to an object, I'm talking about creating another copy of an object.
Please help...
Thanx in advance, Steve.
Copying An Object
I know this is contrary to the nature of VB, but I am trying to find a way of creating a copy of an object without creatinga reference between the objects.
Example:
----------------------------------------------------------------------------
I have a class called MyClass that contains a property called MyProperty. I create an instance of the class and set its properties.
Set MyClass1 = New MyClass
MyClass1.MyProperty = "Test"
I then need to create a copy of the class.
????????
I should then have a new class that contains the same data as the first.
MsgBox MyClass1.MyProperty 'Returns "Test"
MsgBox MyClass2.MyProperty 'Returns "Test"
I should then be able to change the property of the original class without affecting the second class.
MyClass1.MyProperty = "New Test"
MsgBox MyClass1.MyProperty 'Returns "New Test"
MsgBox MyClass2.MyProperty 'Returns "Test"
----------------------------------------------------------------------------
Any advice would be appreciated. I seem to have stumped a great number of individuals with this one.
Jay
Copying An Object
Is there a way in VB of copying a single object multiple times, while preserving the ability to keep the state of one copy while changing the state of another copy of the same type??
Cloning/Copying An Object
Hello,
My first post in this forum, I'm hoping someone can help with something I've been wrestling with for years!
Is there some elegant way to copy an object?
IE: you copy variable x into variable z by saying "x=y". But "Set objX= objY" only points objX to the same object as objY.
There must be an easier way than creating a new instance of the object and then copying each property from one object to the other? Mustn't there? )
Any help much appreciated!
OLEDB Object Copying OWC In VB6
This is a loong shot, but I thought its worth a shot. Maybe someone here has worked with Office Web Component charts and VB6.
Anyways, the problem is this: I have a page with multiple OLEDB containers each holding an Office Web Component Chart. The chart that appears in each container depends on various ListBoxes and ComboBoxes I've setup.
Basically Iam trying to implement a Zoom-in functionality for each chart, whereby clicking on a button or chart and a pop up will appear with a zoomed in version of that chart (basically another larger container).
I can't figure out, how to 'transfer' or 'copy' the chart that has been selected to the zoom-in popup container. Does this make sense?
I'll try to simplify my code to explain it better. Atm its all over the place.
Copying One Object And Making Lots Of Them
I was wonder if it was possible to do so:
I want to be able to make a lot of shapes on the push of a button. I have it set so on vbKeyUp it places a shape I have outside the visible form in the middle of the form. I was wondering if I could hit up and it would make 10 of the same thing?
Copying A Word Document As An Object
Hi All
Please can anyone help me with this problem I need to store a document as an object so I can then delete the original document and then paste the copy back when a user has made some changes here is some code from word.
Dim poDoc as Word.Document
Dim poPrinters(20) as Word.Range
dim poRange as Word.Range
Set poDoc = Application.Documents(1)
' Select Document
Set poRange = poDoc.Content
poRange.Select
Set poPrinters(1) = poRange
poRange.Delete
when the poRange is deleted the poPrinter(1) is deleted as well and help would be great thanks
Edited by - mattman on 10/13/2003 3:18:17 AM
Copying A Word Object Into An Excel Spreadsheet
Hi,
In an Excel (Office XP) macro, I dynamically create a Microsoft Word table (declared as a MSWord Table object - ie. Dim wdTable As Word.Table).
What I would like to do is simulate a "copy and paste" operation. I want to copy the Word table onto the clipboard, then paste it in a spreadsheet cell in a given worksheet called WS1, say at cell B30. I want to paste the object using the special clipboard paste option of "Paste as Microsoft Word Object".
Can anybody help me with the code to do this? Here is what I have so far, but am not sure what part of this is incorrect:
------------------------------------
Selection.wdTable.Select
Selection.Copy
Range("B30").Select
ActiveSheet.PasteSpecial Format:="Microsoft Word Document Object", Link:= _
False, DisplayAsIcon:=False
------------------------------------
Thanks for any help/advice.
-ted
Object Defined Error When Copying Sheets
I've got a function that's supposed to copy all the information from one sheet of a workbook to a sheet in a different workbook. When the app runs - I get hung up with a error code 1004. Application-defined or object-defined error. And I can't figure out why. Here's a portion of the code - that should show you what's going on....
Code:
Sub updinc()
Dim savestring As String
savestring = Application.GetOpenFilename("Excel files (*.XL*),*.XL*")
If savestring <> "False" Then
Dim endrow As Integer
Dim storage As String
Dim obook As Excel.Workbook
Dim ubook As Excel.Workbook
Set ubook = ActiveWorkbook
Set obook = Workbooks.Open(savestring)
If ubook.Sheets("Overview").Cells(22, 6) > obook.Sheets("Overview").Cells(22, 6) Then
For i = 2 To 13
endrow = Module2.FindEnd(obook.Sheets(i).Name)'this function finds the last row in
'the sheet to contain data - in a certain row - depending on other rows - it's weird
'but it returns an integer
If endrow > 1 Then
ubook.Sheets(i).Unprotect "4016"
obook.Sheets(i).Unprotect "4016"
obook.Sheets(i).range(Cells(1, 1), Cells(endrow + 1, 12)).Copy ubook.Sheets(i).Cells(1, 1) 'This is the line that ALWAYS brings up the error...don't know why
obook.Sheets(i).Protect "4016"
ubook.Sheets(i).Protect "4016"
endrow = 4
any ideas?
File Copying Strange Error Message Of Object FileSystemObject
Hello
I'm hoping someone may know the answer to a strange error message I sometimes get while copying files using the FileSystemObject.
The Error Message given is
-2147024832
Method '~' of object '~' failed
When I OK the message box the program exits the sub immediately even though I'm still in the For Next Loop and still have other code to be executed after the Loop
The file is then corrupt as it has not completed copied.
I tried searching the net, etc for this error message and get no results.
The question is is the problem with the FileSystemObject? or something else
The file transfer is other the internet via a VPN, I copy using UNC naming and have tried mapping the drives and this causes the same error message.
And problem only happens with Compiled version of code.
Any help or ideas gratefully received.
Many Thanks in advance
Section of code shown below
General Declarations
~~~~~~~~~~~~~~~~~~~~
Public F As udtFile
Type udtFile
FileArray() As udtFileArray
....
....
End Type
Type udtFileArray
SOURCE_PathFilename As String ' Full Path & Filename
DEST_PathFilename As String
....
....
End Type
Code
~~~~
Dim fsoSysObj As New FileSystemObject
Dim filen As Variant
Dim x As Integer
For x = 1 to Ubound(F.FileArray())
Set filen = fsoSysObj.GetFile(F.FileArray(x).SOURCE_PathFilename)
filen.Copy F.FileArray(x).DEST_PathFilename
Next x
"Copying" An Object
Say I have a class, clsWidget, and I create an instance of this class called oWidget.
What I want to do is to create a copy of my widget object so that I can check later to see if my original has been changed.
But of course if I say
Code:
Set oNewWidget = oWidget
then oNewWidget just points to oWidget and any changes made in the original instance are seen in oNewWidget.
What then is the most straightforward way to create a copy of an object?
Hope you can help, (and a happy new year to you all!)
If No Listview Object, Can Changed List Object?
If no Listview object, can changed list object?
Hello, I have problem.
If my VB project to used "Listview" Object
But my .EXE file goto other computer run. Said error : no comctl32.ocx/mscomctl.ocx
must stop processing ?
Can use IF() to changed ?
Form_Load()
If Dir$("C:windowssystem32comctrl32.ocx") Here ,
Run Form2.Listview1 Object
Else
Run Form3.List1 Object
End if
?Possible ? Please!
BTW: Becuase I can't install OCX pack. No administrator user.:
Copying Listviewitems To Another Listview(another Form)
hi guys, I am trying to copy the items on my first listview(from form1) to the second listview(form 2)
I having some problem doing this, and I don't know what I've been doing wrong..
right now I'm using this code
vb Code:
X = 1For N = 0 To Me.lvwOutPerif.ListItems.Count - 1Set lstItem = frmDataEntry.lvwHistoryPerif.ListItems.Add (, ,Me.lvwOutPerif.ListItems(X) lstItem.SubItems(1) = Me.lvwOutPerif.ListItems(X).ListSubItems(1).Text 'Error occurs here saying that says invalid property value X = X + 1Next N
Copying File From Folder Using ListView
I have a list view control that I have populated from a recordset. When I do a double click event on an item in the list view, I want to fire an event where I read the DB for the path leading to an image file in a folder.
How do I do this?
Code:
Private Sub lvwResults_DblClick()
Dim conn As ADODB.Connection
Set conn = New ADODB.Connection
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Dim sql As String
dlgOpen.Filter = ""
sql = "SELECT * FROM FileExtensions ORDER BY FileExtensions"
conn.ConnectionString = "Provider=Microsoft.JET.OLEDB.4.0;Data Source=" & App.Path & "dbGraphics.mdb;Persist Security Info=False"
conn.CursorLocation = adUseClient
conn.Open
rs.Open sql, conn, adOpenStatic, adLockOptimistic
With rs
Do While Not .EOF
dlgOpen.Filter = dlgOpen.Filter & "|" & .Fields("FileExtensions") & "|" & .Fields("FileExtensions")
.MoveNext
Loop
.Close
dlgOpen.FilterIndex = 1
End With
conn.Close
Set rs = Nothing
Set conn = Nothing
dlgOpen.ShowSave
Dim objDownLoad As FileSystemObject
Set objDownLoad = New FileSystemObject
Dim rs2 As ADODB.Recordset
Set rs2 = New ADODB.Recordset
Dim conn2 As ADODB.Connection
Set conn2 = New ADODB.Connection
Dim sql2 As String
sql2 = "SELECT * FROM Master.Path WHERE Path = '" & lvwResults.SelectedItem.ListSubItems & "'"
MsgBox sql2
' objDownLoad.CopyFile
Copying Data From A Listview Row To A Textbox In Another Form
To illustrate well, I have provided the following screenshots.
What I want to happen is, from this form
http://img.photobucket.com/albums/v3...shots/View.gif
When I click on a particular record/row, then click the View button, another form should appear, like this
http://img.photobucket.com/albums/v3...ts/Details.gif
containing the same data as in the listview, placed on the corresponding fields, of course.
Now, I can do this only for the first record/row in my listview. How do I do it for all of them so that when I click on the next record, say matt's record, the Feedback Details form will indicate the details of matt's record?
ListView Object
How do you use the ListView Object while importing data from a txt file. I need help, let me know if you want to see the file then maybe I can give you my aim or messenger. Thank You.
ListView Object
I am having some difficulty with the list view object. I created an activex control to superclass the standard ListView control. I want to be able to pass through the ListView's ListItems so that they can be accessed by the form that I place the control on. Here is the code in the activex control:
Code:Public Property Get HighlightedRecord() As ListItem
Dim itmx As ListItem
If lstParentList.ListItems.Count > 0 Then
Set HighlightedRecord = lstParentList.SelectedItem
Else
itmx.Text = "Empty List"
Set HighlightedRecord = itmx
End If
End Property
* In the example 'lstParentList' refers to the standard ListView control.
With this I have a couple of problems. Firstly when there are records in the list and the function returns the 'SelectedItem' I get a 'Type Mismatch' error on the line of code in the main program that reads:
Code:Dim itmx As ListItem
Set itmx = lstOrderServices.HighlightedRecord
* Where 'lstOrderServices' is the activex control.
The only way I can seem to get around this is by changing 'Dim itmx As ListItem' to 'Dim itmx As Object'. Can this be prevented?
The other issue i have is when there is no record in the list, I want to return a new instance of 'ListItem' with the value of 'Empty List'. Is it possible to instantiate a new object of type 'ListItem'? I tried something along the lines of 'Set itmx = new ListItem' with no success.
Hope someone can help me, this has been driving me nuts.
Thanks in advance,
Nigel Murden
Properties Listview Object
I'm searching for object (in components) like the one in Visual Basic 6 - Properties Window.
So, is there such object - listview with grid and all you have to do is add your properties.
So is there such object (and in what component group)?
If not, what would be the easiest way to do it (ListView, Flextgrid object...)
THX very much,
Rok
Copy Listview Object
Hello!
It is possible to copy the listitems for one listview to another without make a cycle ?
Thanks
ListView + Object Variables
Code:
Dim strTemp As String
Dim strText As String
Dim Control As Object
Dim ColumnIndex As Integer
Private Sub Form_Load()
Open "C:InfoData.txt" For Input As #1
Do Until EOF(1)
Line Input #1, strTemp
strText = Right(strTemp, Len(strTemp) - 1)
Select Case Left(strTemp, 1)
Case "-"
Set Control = strText
Case "*"
ColumnIndex = ColumnIndex + 1
AddColumn Control, ColumnIndex, strText
Case ":"
AddText Control, ColumnIndex, strText
End Select
Loop
End Sub
Public Function AddColumn(List As Object, Index As Integer, Text As String)
List.ColumnHeaders.Add Index, , Text
End Function
Public Function AddText(List As Object, Index As Integer, Text As String)
Dim ListObj As ListItem
Set ListObj = List.ListItems.Add(1, , Text)
ListObj.SubItems(1) = Text
End Function
What's wrong with that?
I want it to switch control when it gets a line starting with '-'
I want it to Add a columnheader when it gets a line starting with '*'
I want it to Add to a column when it gets a line starting with ':'
Thanks.
ListView - Object Not Supported
Can anyone explain why I am receiving this error, "Object doesn't support this property or method" when I attempt to retreive a ListView called from a function?
My Code:
Private Sub Form_Load()
ListView1 = getlistview(ListView1)
End Sub
Function getlistview(mylistview As ListView) As ListView
mylistview.ListItems.Add , , "Fred"
mylistview.ListItems.Add , , "Sarah"
mylistview.ListItems.Add , , "Paul"
Set getlistview = mylistview
End Function
Thank You,
Pass A Listview Object To A Dll
Is it possible to pass a list view object to a dll?? as of right now it won't let me because if i declare the function as public.. it says that i can't use a private object module as a parameter for a public function...
the reason i am doing this is because i have about 9 apps here at work and they share a dll that has a lot of common functions.. and one of the functions i would like to put in is a listview sorting function.. but i don't want to include it in every app. i would rather put it in the dll to call..
Object Over ListView Question
Hi,
It seems that you can't place any objects over a ListView even when you specify the zorder of that object as 0.
I'm trying to accomplish the following:
If the ListView has no data, I want a label to appear near the top center of the empty ListView which says "There are no items in this view.", kinda like Outlook Express does when there is no email in a folder.
Is there any way to accomplish this?
Thanks,
Dan
Creating A Listview Object
Hi,
Does anyone know how can we create a free standing listitem object **without** setting it to any listview controls ?
For example I would like to create a listitm objectwith some default data and then use it to assign those default data to any new listitems of a listview.
For example (though it does not work)
Suppose there is a listview names LIST_V1
'---------
Dim DefaultItem as listitem
defaultitem.text = "Untiltled"
Defaultitem.listsubitems.add 1, ,0
Defaultitem.listsubitems.add 2, ,-1
LIST_V1.listitems(1) = defaultitem
'-----------
Listview Question - How To Tell If An Object Has A Parent?
I've got a listview, that has groups, which have nodes. How can I tell if a node doesn't have a parent? I need to determine (in a listview_nodeclick event) whether a root node or sub node was clicked - is there an easy way to do it? I've tried checking to see if the Node passed to _NodeClick would work, but it always returns false (since I'm using linestyle1 (tvwRootLines).
Programmatically Select Row In ListView Object
I am using a listview with the View property set to Report to display data from a file.
I want to have the program scan thru the listview abd highlight the row containing a specified datum.
I've tried several attempts but can't get it to select (and highlight) the row. I have the FullRowSelect property set to true so the row should be highlighted if it is selected.
I've managed to run a search thru the list of displayed items and identify the row I want by the index but I can't figure out how to get the selection set to that row.
Thanks for any assistance.
Added info: If I manually select a row, the highlight moves to the new program selected row. I guess what I need it to set the row highlight initially via program control.
Respond To Del Key Only When Listview Object Has Focus.
I set Del as a shortcut key for one of the menu items in my program, the problem is, if someone tries to delete text in a text box it triggers the menu action. I know I could use got & lost focus events on the listbox and then put If blnListFocused Then <delete> but that would disable the menu item itself as well which I want to work no matter what has the focus.
Thanks
ListView Problem - Object Variable Not Set
I am trying to use ListView to display a series of records read from a file.
I set up all of the parameters using the properties page and the ListView box on the form configures itself accordingly.
But, when run, I keep getting an error message stating that the object variable is not set with the Set itmX statement highlighted.
My references says nothing about setting an object variable. I cannot find any discussion about how to set an object variable! I patterned my code after the example in Using Visual Basic 6: Special Edition, 1998.
An associated problem - maybe the real problem - is that the Add method in the statement will not accept a blank, optional smallIcon parameter.
What am I missing?
Here's the relevent code:
vb Code:
Private Sub cmdReadFile_Click() Dim sDate As String Dim sPhase As String Dim sSigns As String Dim sComments As String Dim ListView1 As ListView Dim itmX As ListItem Open App.Path & "RateFile.TXT" For Input As #1 While Not EOF(1) Input #1, sDate, sPhase, sSigns, sComments Set itmX = ListView1.ListItems.Add(, , sDate, , Null) itmX.SubItems(1) = sPhase itmX.SubItems(2) = sSigns itmX.SubItems(3) = sComments Wend Close #1 End Sub
Deleting Rows From ListView Object
Does anyone know how to delete rows from the ListView object? Is there a good place on the Internet where I can find information on this object's properties and methods?
Thanks...
ActiveX Component Can't Create Object Or Return Reference To This Object (Error 429)
MSDN talks about the "registry" and "setup program". I'm a beginner and CLUELESS! I tried to install Active X references and got the following notice: Name conflicts with existing module, project, or object library. The last line is where I get the run-time error in VB6:
Dim ppApp As PowerPoint.Application
Dim ppPres As PowerPoint.Presentation
Dim ppShape As PowerPoint.Shape
Dim ppCurrentSlide As PowerPoint.Slide
Dim msoTrue As New OLEObject
Dim msoFalse As New OLEObject
Dim oPicture As New OLEObject
Set ppApp = CreateObject("PowerPoint.Application")
ppApp.Visible = True
Set ppPres = ppApp.Presentations.Add(msoTrue)
Hope someone can help me....thanks Warren
How Can I Create Run-time Object References For Objects Of Office Object Model?
My problem is, that I don't know, how to create a reference at run-time to a word application object.
For example:
Dim myWordApp As Object
Set myWordApp = CreateObject("Word.Application")
Than I have a reference to a word application.
But, how can I check the value of myWordApp.Activedocument.Paragraphs(1).Alignment dynamically, if at compile-time I don't know yet, whose value I want to check, because it is generated from a string?
"Activedocument.Paragraphs(1).Alignment"
or
"ActiveDocument.Paragraphs(1).LineSpacing"
or
"ActiveDocument.CodeName"
...
Can I Write The Data In Printer(global Object) Object DC To A File?
Hi,
I have an existing function which pushes the data on to the Printer (global) object
in the required format. Now I got to add another functionality to save the same data in a word doc.
I don’t want to take the risk involved in formatting the data again in word document,
as I’m not comfortable with the formatting methods in word.
Is there any way to use the same Printer Object for writing the data to a file, similar to what Microsoft office document image writer do?
Thanks & regards,
Sowjanya.
*RESOLVED* Identify Object Library To Which Object Belongs
Hi,
I have inherited a VB6 application which was written by someone who is no longer with the company.
I need to distribute his application but I have noticed that he used some objects from the Forms2 object library.
As you are not allowed to distribute applications that use this library, I have to work through his application and replace forms2 objects with others.
I have replaced the obvious ones (spin button) but when I try to remove the Forms2 component from the project, it tells me that some controls are still in use.
How can I tell which objects belong to the Forms2 library?
As always, any help greatly appreciated.
Error Message - Object Reference Not Set To An Instance Of The Object
Can anyone help - I am trying to add a record (with no success!) The following code comes up with the error message Object reference not set to an instance of an object.at the line marked (***). Must be a simple reason but I can't work it out...
Cheers
John
Private Sub btnAddUser_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddUser.Click
OleDbDataAdapter1.Fill(DsAllProfile1, "tblProfile")
Dim objTable As DataTable
Dim drRows As DataRowCollection
Dim objNewRow As DataRow
objTable = DsAllProfile1.Tables("tblProfile")
drRows = objTable.Rows
(***)objNewRow("Default") = CBool("1")
objNewRow("ProfileWeight") = 233
objNewRow("ProfileName") = "Pablo"
objNewRow("ProfileDOB") = "23/02/71)"
objNewRow("ProfileSex") = CBool("1")
drRows.Add(objNewRow)
End Sub
Setting An Object Equal To Another Object (quick Question)
if i were to do this:
VB Code:
Dim m_obj As ADODB.Connection Public Property Let Blah(pNewObject As ADODB.Connection) Set m_obj = pNewObjectEnd Property
would m_obj then be the same connection that i pass in to the property, or would it be the same as creating a completely new instance?
thanks
Runtime Error 429 ActiveX Object Cannot Create Object
Hi All,
Am getting the following error,
"RunTime error 429
ActiveX Object Cannot Create Object"
The same application runs fine in other machines, but it throws error inNT Server.
Your help will be highly appreciated,
Thanks in advance,
Badri
Need To Create A Connection Object For An Existing Database Object
Below is a fragment where I create a local database and table
which I fill with data from a remote source....
Dim wDef As Workspace
Dim oDB As Database
Dim oTD As TableDef
Dim oRS As ADODB.Recordset
'
' Get default Workspace.
Set wDef = DBEngine.Workspaces(0)
'
' Make sure there isn't already a file with the name of
' the new database.
If Dir(cLocalDB) <> "" Then Kill cLocalDB
'
'create new database
Set oDB = wDef.CreateDatabase(cLocalDB, dbLangGeneral)
'
'Create a new table
Set oTD = oDB.CreateTableDef("JobMapDraft")
With oTD
'Create fields and append them to the new TableDef
'object. This must be done before appending the
'TableDef object to the TableDefs collection of the
'new database.
.Fields.Append .CreateField("DayNo", dbLong)
etc...
'
' Append the new TableDef object to the Northwind
' database.
oDB.TableDefs.Append oTD
End With
Set oRS = New ADODB.Recordset
query = "insert into JobMapDraft ...............
oRS.Open query, oDB, adOpenDynamic, adLockOptimistic ****
oDB.Close
This stalls at **** with a 'Run-time error 3001: Arguments of wrong type....' error
Now, as it happens, I know precisely why this fails - the oRS.Open statement **** needs a Connection object rather than the Database object oDB.
What I would like to know is if there is any way I can create a Connection object from the Database object oDB, or attach a Connection object to it, rather than closing the Databse and using a Connection to it - I would have thought this a sensible facility for MS to include, but you know MS
Leo Sutherland
Leo
-------------------------------------------------------
Time flies like an arrow, Fruit flies like a banana
User Defined Object No Worky With Collection Object
I have an object I created, TextParser which parses some text and stores some info. I want to essentially have a list of TextParsers, which I can traverse and delete and add to. I seem to have problems adding these objects to a Collection object because it says (run time error) method or property not supported. So it seems I can only add numbers and
strings to a Collection object?
I'm also curious about other Collection like classes, for example queues, priority queues, stacks, vectors, trees, maps, etc.. if they exist at all in the VB world.
How can I work around this or have I missed something? This would work in c or c++
parser.Add(new TextParser) does not work either..... tried that.
I have the following code stuck in a userform in a VBA project for excel 2000. initMe is something I tried after the code in the initObject (or whatever it is) flubbed, it flubbs here too. I tried changing the instancing property back and forth and that did nothing too.
It borks right at the .Add line.
Private parsers As Collection 'collection of parsers
Private parserIndex As Long
Public Sub initMe()
parserIndex = 1
Set parsers = New Collection
Dim p As TextParser
Set p = New TextParser
parsers.Add (p) ' problem is here
Set p = Nothing
End Sub
Listview Object Losing First Item In Source Recordset?
I'm being such a pest today, I know...but this is really weird. When I first ran this code, all of the teams showed up correctly in the list view. Then I started playing around seeing if I could break it, and deleted the first entry. Of course it's still on the DB because the app user doesn't have permission to delete data. I would have expected it to show up again when I next ran the code, but it didn't. It's in the DB, always shows up as empty in the listview object. It's not like it cuts off the first record; it just blanks it, if that makes any sense.
The code:
Code:
Public Sub PopTeamList()
Dim strSQL As String
Dim rst As ADODB.Recordset
Dim lstTeam As ListView
Dim itmx As ListItem
Dim colx As ColumnHeader
strSQL = "SELECT Team, Cases FROM vwFETeamList WHERE Team IS NOT NULL ORDER BY Team"
Set lstTeam = CriteriaSelection.lstTeam
With lstTeam.ColumnHeaders
Set colx = .Add(, , "Team")
Set colx = .Add(, , "Cases")
End With
Set rst = New ADODB.Recordset
rst.Open strSQL, cnConn, adOpenForwardOnly
lstTeam.Visible = False
Do While Not rst.EOF
Set itmx = lstTeam.ListItems.Add(, , rst.Fields(0))
itmx.SubItems(1) = rst.Fields(1)
rst.MoveNext
Loop
lstTeam.Visible = True
lstTeam.View = lvwReport
rst.Close
Set rst = Nothing
Set lstTeam = Nothing
Set itmx = Nothing
Set colx = Nothing
End Sub
|