Index Of Newly Added Item In Sorted Listview
I need to find the index number of the item last added to a listview. I can use listcount, except if the user clicks on the column header and sorts the list, then the next item added could be listed in the middle of the items already in the list. So .ListCount would not work in that situation. So if I have a listview with items #1,#2,#3, and I add an item which is placed in between #1 and #2, how can I find out it's spot in the list????
Any ideas or direction would be very helpful.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Listbox: How To Know Last Added Item's Index, When The Listbox Is Sorted?
When sorted property of a listbox is set to True, each new item added won't be at the end of the list, it will be automatically placed in the correct index, according to text order, is there a way to know which is the index of that item (last item added)? Looping to find it would be horrendous, I just need the index to mark that item selected.
Click Item In Listview Then Show That Item In Combo As Index = 0
Hi guys,
I have a listview (lvwUserPunchedOut) that is populated with records in a database (persons first name in one column and last name in the second column), what I am looking to do is if I select a persons name by clicking on it in the listview on frmMain, and then bring up frmSearchCriteria, i would like to show that selected name in the combobox as default (cboEmployee.ListIndex = 0) on frmSearchCriteria (the combobox is sorted = True and is also populated with first name and last name of the person)
How would this be done? Hope I make sense. Thanks in advance.
Show Last Item Added In Listview.
Hello there! I just wanted to ask if there's any way to display or go to the last item added in a listview. I have this attendance system and it's working out fine. But they want to see that during scanning, their name should be displayed as it's added to the listview. There will be no user intervention by the way as the computer is inside a cabinet with just the barcode scanner the interact with.
Listview Item Added Event
I was just wondering if there was a way of triggering an event when an item is added to a ListView control.
I am making a server browsing app, and due to the design of it, I need to trigger an event when a new server gets added to the list (so that I can add ping values, etc.)
Would subclassing the control be suitable for this requirement? I'd prefer it if there was another way, because I'm not 100% sure how to subclass a control as I've never had to before, and also because it might either slow down the app considerably or cause it to crash. It queries about 30-50 servers per second, so the method used would need to be as fast as possible.
Thanks.
How To Print Just Added Item To The Listview
I have a Listview when I add item then I press the buttom cmdsave I save the data to the database and the sametime I print all items to the printer
This how I print
Code:
Open "COM1" For Output As #1
Print #1, "VB6 RESTAURANT"
Print #1, "======================================"
For i = 1 To ListView1.ListItems.count
Line = (ListView1.ListItems(i).ListSubItems("Qty") & _
(ListView1.ListItems(i).ListSubItems("Description")))
Print #1, Line
Next i
Print #1, "======================================"
I save the items to the database and print the "Order" if the Order is still open, the user can add new item and can see those items that he save it before but, but here is my question.
How can I Just print the new item that I add to the listview without print the others.
Listview- Display Most Recent Added Item On Top
Hi,
I have a small problem with listview sorting....coz right now, my most recent added item appears at the most bottom row. And I've this limited area of listview that can only display 4 rows. Thus, when i add more than 4 items, the rest of items does not appear on the listview immediately. So, i have to scroll the vertical bar to locate the last added item.
Wonder if VB provides a function whereby the most recent added item can be displayed at the top of the listview instead. And probably it can also get selected to show that it's the most recent item added(the next feature).
If not, any suggestions?
Thanks
How To Play Wave Sound When An Item Is Added To Listview?
Could any one show me how i can play a wave sound only once when new row is added to listview? The code beleow is used to populate listview.
1 Code:
Private Sub PopulateListview()
Dim objDoc As MSXML2.DOMDocument
Dim objNodelist As IXMLDOMNodeList
Dim objNode As IXMLDOMNode
Dim lvwItem As ListItem
If objDocCopy Is Nothing Then Exit Sub
Set objDoc = objDocCopy
'add all the song nodes into a nodelist
Set objNodelist = objDoc.selectNodes("//song")
'Clear the listview
ListView1.ListItems.Clear
'Loop through each song node and add to the list view
For Each objNode In objNodelist
Set lvwItem = ListView1.ListItems.Add(, , objNode.selectSingleNode("artist").Text)
lvwItem.SubItems(1) = objNode.selectSingleNode("name").Text
lvwItem.SubItems(2) = objNode.selectSingleNode("image").Text
lvwItem.SubItems(3) = objNode.selectSingleNode("rating").Text
'lvwItem.SubItems(4) = objNode.selectSingleNode("songid").Text
lvwItem.SubItems(4) = objNode.selectSingleNode("totalvotes").Text
lvwItem.SubItems(5) = objNode.selectSingleNode("page").Text
lvwItem.SubItems(6) = objNode.selectSingleNode("referrer").Text
lvwItem.SubItems(7) = objNode.selectSingleNode("pageWindowName").Text
Next objNode
Set lvwItem = Nothing
Set objNodelist = Nothing
Set objDoc = Nothing
End Sub
Allow Zero Length For Newly Added Column
This is the function I am making to create a new column in a certain table if is doesn't exists, what I'm after is to make the newly added Column set to Allow Zero Length, anyone who could share a snippet?
VB Code:
Public Function ColumnExists(ByVal pValue As String) As Boolean Dim oRstOne As ADODB.Recordset Set oRstOne = cnn.OpenSchema(adSchemaColumns, Array(Empty, Empty, "DCDynamicTable", Empty)) ColumnExists = False With oRstOne Do While Not .EOF If .Fields("COLUMN_NAME").Value = pValue Then ColumnExists = True Exit Do End If .MoveNext Loop .Close End With Set oRstOne = Nothing If ColumnExists = False Then cnn.Execute "ALTER TABLE DCDynamicTable ADD COLUMN " & pValue & " TEXT(50)" End IfEnd Function
Updating DataSource With Newly Added Rows In DataSet
I am trying to convert a C++ program into VB.Net (in an attempt to learn VB). I am having trouble writing changes I made to a DataSet back to the Access2002 DB. I get a runtime error: "An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll" Below is the area of the code that is throwing the exception:
Code:
Dim szQuery As String = "Select * From Employee;"
g_Utilities.db.Connect(g_szDBPath)
Dim dscmd As New OleDbDataAdapter(szQuery, g_Utilities.db.cnConnection)
Dim ds As New DataSet()
dscmd.Fill(ds, "Employee")
Dim dtResult As DataTable = ds.Tables.Item("Employee")
Dim rowNew As DataRow = dtResult.NewRow()
'code adding new row here
'add the new row to the table results & update teh table in DB
dtResult.Rows.Add(rowNew)
dscmd.SelectCommand = New OleDbCommand(szQuery, g_Utilities.db.cnConnection)
Dim cmdbld As OleDbCommandBuilder = New OleDbCommandBuilder(dscmd)
dscmd.Update(ds, "Employee") 'this is where the exception is thrown
g_Utilities.db.Disconnect()
frmTempEmpData.Close()
Does anyone know what I need to do to get this to work. I have been going over the MSDN help on this topic as well as a few books and I am doing what they say. I am probably missing some finer detail or something. But I can't figure it out.
Any help is appreciated!!
Thanks
Retrieve Auto-number Primary Key Of Newly-added Record
This is a "newbie" question, which I've translated into the usual "customer and order" paradigm.
I have a Customers table and an Orders table. The primary key of the Customers table is an auto-number field ("CustomerID") which also appears as one of the fields of the Orders table. I have a user input form which gathers information about a new customer and a new order, and appends a record to both tables.
The question is, how do I capture the CustomerID value of the newly-added customer record, in order to put its value into the new order record? Here is some stripped-down code:
Code:
'Using DAO architecture
Dim MyDatabase As DAO.Database
Dim RS As DAO.Recordset
< Much code for various controls on this form, to assign..>
< variables representing Customer fields and Order fields >
Private Sub AddNewOrder() 'Adds both a customer and an order
Set MyDatabase = CurrentDb
'First, append a new customer record
Set RS = MyDatabase.OpenRecordset("tblCustomers")
With RS
.AddNew
![CustomerField1] = <varMyCustField1>
![CustomerField2] = <varMyCustField2>
< etc.>
.Update
.Close
End With
'Now append a new order record
Set RS = MyDatabase.OpenRecordset("tblOrders")
With RS
.AddNew
![OrdersField1] = <varMyOrderField1>
![OrdersField2] <varMyOrderField2>
< etc.>
![CustomerID] = < ??? >
.Update
.Close
End With
End Sub
OK, so my question is: What do I put in place of < ??? > in
the above code? Thanks in advance for any help.
--Andy
Retrive Index Of Item In Listview?
How the hell do i retrive the index of an Item in a listview control?!
Sometimes I just hate this cnotrol...its too complicated...
Anyone?
Setting Listview Item To An Index Number
Ive been using the following to set the selected item in my listview:
VB Code:
MatchFiles.SelectedItem = MatchFiles.ListItems(OldName)
which sets the current item equal to that contained in 'OldName'.
Is there a command similar to set the selected item to an index number? So i could set row 7 to selected? Thanks
Problem Transfering Listview Item To Textbox With Index
Hi all i got a listbox called listbox2 and it has some url on it. I want to transfer listbox item to a textbox once i click on listbox item .But when i try the follwoing with a textbox that it index property set to 0 i get error :
VB Code:
compile error: Invalid use of property
code:
VB Code:
Private Sub Command1_Click() txtURL2 = List2.Text ' put the value of listbox to textbox txturl End Sub
I tried the same method with textbox that its index property is empty and it worked fine but it does not work with textbox that its index property set to 0. I be happy if some one help me here.Thanks
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!!
Index Of Newly-created Record Is Zero
I have a database project that adds a new record to a table, then sends the index of the newly-created record to a field in another table. The problem I am having is that the index is always zero until I close the recordset. I had this problem before and I think it was caused by having two recordsets set to the same table open simultainously. I have checked my code and there is only one recordset open. Anyone have any idea of what might be causing this?
Index Last Added Image
I am using a DHTMLedit control in ma VB6 app.
I have a 'add picture' button and I add a picture in my DHTMLedit document as follows
DHTMLedit1.execCommand DECMD_IMAGE,OLECMDEXECOPT_PROMPTUSER
This works but now i want to get the image index so i can change the attributes.
As soon as I add the image, the added image hasn't got the focus, so or i set focus on the image (but how) it has no id/name and what's is index?
I tried something like
tk = DHTMLEdit1.DOM.images(DHTMLEdit1.DOM.images.Length-1).Src
But the problem with length -1 is that this gives only the last positioned index (on bottom of the page) on the page and not the last added one.
So i have to use something else, any ideas?
Edited by - lvermeersch on 9/8/2005 6:22:40 AM
Selecting First Item In Sorted Treeview
Hi,
I have a somewhat simple problem and I am wondering what the simplest way to handle it is. I have a treeview that I am loading with some information about files in a specific directory. The listview is set to automatically sort the list and after all the nodes are added, I want to have the top node in the treeview be selected. But I don't have a reference to the first node in the list. Are there any properties that I can use to get the node that is at the top of the list?
Thanks,
Jason O
Sort Vba Listbox After New Item Added
I have a listbox which I want to sort after a new item has beed added. My code is as follows:
Code:
With Name
i = .ListIndex
i = i + 1
.AddItem , i
s = InputBox("Please enter name: ")
If s = "" Then
.RemoveItem i
Else
.List(i, 0) = s
.List(i, 1) = s
End If
End With
Dim vaItems As Variant
Dim p As Long, q As Long
Dim vTemp As Variant
vaItems = Me.Name.List
For p = LBound(vaItems, 1) To UBound(vaItems, 1) - 1
For q = p + 1 To UBound(vaItems, 1)
If vaItems(p, 0) > vaItems(q, 0) Then
vTemp = vaItems(p, 0)
vaItems(p, 0) = vaItems(q, 0)
vaItems(q, 0) = vTemp
End If
Next q
Next p
'Clear the listbox
Me.Name.Clear
For p = LBound(vaItems, 1) To UBound(vaItems, 1)
Me.TeamCode.AddItem vaItems(p, 0)
Next p
End Sub
The code works fine until I add the sort code (also found on this forum, I think by Timbo?), it causes a type mismatch error at:
'For p = LBound(vaItems, 1) To UBound(vaItems, 1) - 1'
Any idea what I have done wrong?
Showing The Latest Item Added To A ListBox
Hi,
I have a listbox to which I'm adding new items. The listbox is high enough to show 6 items without having to use the scroll bar.
When the listbox gets more than 6 items, I want it to scroll automatically to the bottom of the list to show the latest items without having user to use the scroll bar.
How do I do this?
Thanks.
Is It Possible To Subclass A Menu Item Added To Another Appliction?
I've tried numerous times, and failed, to gain control of a menu subitem added to a menu in an existing application.
I am trying to create an addon to a program that does not have an exported object model to play with.. I have been able to create a menu item with subitems under it but have been unsuccessful in subclassing the wndproc for these menu items to control them when clicked on.
I am currently using Win2k and VB6 sp3. Does anyone know of a way to do this?
(I heard of problems w/ setwindowlong replacing windowprocs in 2000 unless the software is part of the same process thread. I even Tried attaching my process to the other applications process thread, however unsuccessfully).
Thanks in advance.
--NipsMG
Determining The Length Of The Longest Item Being Added To A Combo Box
I have no idea if this is possible, but here is what I'm told needs to be done.
I have to add three items to a combo box (ListViews or third party components are not an option).
The second item is the name of an insurance company, which can vary in length.
As the combo is being populated, I need to determine the length of the item, and add the third item one space over. If the next item that is being loaded is the same length or shorter, I need the third item to be loaded in the exact same spot as it was the last time. If the next item being loaded is longer than any previous item, I need to add one to its length and MOVE everything that has been previous loaded over to that location so that at the end of the combo load, the third item lines up in a nice, neat, little row.
I've told my boss that I don't believe this is possible but I want to double check with you guys.
(PS: I have no sample code to post 'cause I wouldn't even know where to start on this one. )
Listview Sorted Property
Greetings all:
I have an app that contains 3 listview controls. I want the items in each
list to be sorted, so at design-time I set the sorted property true,
sortorder ascending, sortkey 0. That seemed fine at first. However, VB
treats numbers in the listview as strings, which really hoses up a sorted
list. Given the following numbers, this is how they would sort.
2
31
32
35
4
788
790
8
and so on. Does anyone know a quick way around this, or must I either write
my own sort routine or abandon the idea of a sorted list all together. (Out of the last 2 options, I would have to
choose the latter; although experienced in other languages, I am new to VB).
Thanks,
Clark
ListBox: Automatically Scroll So Last Item Added Is Shown At Bottom
Maybe listbox is not the best way to do this, but here's what I want:
Program creates log records to display to user what tasks the program is performing. The log records are displayed in chronological order as they are written. Whenever a new record is written, it will be the last one visible within the list box. If the list box can show 4 records, when record 5 is written, you'll see records 2-5 in the list box, when record 6 is written you'll see, records, 3-6 in the list box, etc.
I used SendKeys like so ('li' is the list box index):
If li Mod PageSize = 0 Then
SendKeys "{PGDN}"
End If
But the problem is that if the user interacts with the application at all, this gets messed up. Also, if the app is minimized, then SendKeys affects whatever app the user is currently working with.
In searching the listbox threads I saw a post where the ListBox.SetFocus was done before the SendKeys, but that seems like it that would also interfere if the user had switched to a different app.
Ideas?
Jim
How To Add SubMenus Or Item In A Menu(popup) In Run Time , Need To Added More In List
Hi,
In my project, in a grid control, i list all AreaName, when the user click one Area and Right Click, then ther will be a menu called 'List All Equipment Under This Area', So how can i load All The Equipment Under this menu, when the User selected Area and click 'List All Equipment Under This Area'. I can select them through query , but how i will load them in the Menu. Through code how to do add them in the Menu, may be there will be more the 100 Equipments to be added some times and more over that these Equipments should be added when the user clicks the 'List All Equipment Under This Area', is it possible. Kindly if there is any sample or linkk give me.
Thankyou,
Chock.
How To Add SubMenus Or Item In A Menu (popup) In Run Time , Need To Added More In The List
Hi,
In my project, in a grid control, i list all AreaName, when the user click one Area and Right Click, then ther will be a menu called 'List All Equipment Under This Area', So how can i load All The Equipment Under this menu, when the User selected Area and click 'List All Equipment Under This Area'. I can select them through query , but how i will load them in the Menu. Through code how to do add them in the Menu, may be there will be more the 100 Equipments to be added some times and more over that these Equipments should be added when the user clicks the 'List All Equipment Under This Area', is it possible. Kindly if there is any sample or linkk give me.
Thankyou,
Chock.
How Do I Get The ListView Sorted Order After Sorting?
I have a fully functional ListView, automatically sorted numerically (thus, I've been able to solve a couple of common problems all by myself). But the sort appears to be only on-screen -- the indexes for the items are unchanged.
How can the rest of my program determine the sorted order? Or, how can I transfer the sorted data back to an array in the displayed order?
My hope was to use the ListView sort function as my sorting mechanism, avoiding the need to write a separate sort subroutine...
Listview - Get Last Added Value
Hi,
I have a listview on a form and a textbox. When I enter text in the textbox and hit return it adds it to the listview - no problems so far.
I'm not trying to stop duplicates by checking the last row in the listview and if it's the same as the textbox then disregard it.
VB Code:
If serials.ListItems.Item(serials.ListItems.Count).Text <> serialindiv.Text Then serials.ListItems.Add , , serialindiv.Text Else End If
That's the code I am using now, and I've tried a few variations on it, but still cant get it to work.
Any help would be much appreciated.
Cheers,
Sparky.
Get The Item Index
I have a UserControl that uses two classes the individual class and a collection class, how I can implement into the Individual class to get te Index number into the collection class ???
like ListItem and ListItems
Example:
Dim LstItem as ListItem
Set LstItem = ListView1.ListItems(1)
'I want this
Msgbox LstItem.Index
'This prints 1
Thanks !!
Tab Index To Get To Next Item
I have set up the tabindex on my form to go to the correct place when the tab button is pressed. I need it to select the text in the text box when the tab button is pressed. Right now it goes to the begining of the text box but does not select the information in the text box. Any ideas would be appreciated.
Problem With Listview Column Sorting (numbers Not Getting Sorted Properly) ...
Hello!
I'm trying to sort the data in a Listview that contains the list of Files/Folders along with their sizes in sub-item. I want to sort the listview content based on Size. However, I found that Listview control does not recognize the numeric data as Numbers and it treats it as Strings while attempting to sort. I found that number 9.1 is shown above 81! This is not a correct sorting, right? Is there any solution for this?
To make my query clear, I have created a small Demo program. Please see the code, run the program and you will realize what I'm talking about. Is there any solution for this? I'm not finding any. I have attached the code to this comment.
Waiting for your reply ...
Regards,
Ruturaj.
Problem With Listview Column Sorting (numbers Not Getting Sorted Properly) ...
Hello!
I'm trying to sort the data in a Listview that contains the list of Files/Folders along with their sizes in sub-item. I want to sort the listview content based on Size. However, I found that Listview control does not recognize the numeric data as Numbers and it treats it as Strings while attempting to sort. I found that number 9.1 is shown above 81! This is not a correct sorting, right? Is there any solution for this?
To make my query clear, I have created a small Demo program. Please see the code, run the program and you will realize what I'm talking about. Is there any solution for this? I'm not finding any. I have attached the code to this comment.
Waiting for your reply ...
Regards,
Ruturaj.
Problem With Listview Column Sorting (numbers Not Getting Sorted Properly) ...
Hello!
I'm trying to sort the data in a Listview that contains the list of Files/Folders along with their sizes in sub-item. I want to sort the listview content based on Size. However, I found that Listview control does not recognize the numeric data as Numbers and it treats it as Strings while attempting to sort. I found that number 9.1 is shown above 81! This is not a correct sorting, right? Is there any solution for this?
To make my query clear, I have created a small Demo program. Please see the code, run the program and you will realize what I'm talking about. Is there any solution for this? I'm not finding any. I have attached the code to this comment.
Waiting for your reply ...
Regards,
Ruturaj.
Cannot Get Index Of Item In Combo
i have added each printer on the system to a combo box:
for each prn in printers
cboPrinter.additem prn.devicename
next
then set the first item to be systems default printer:
cboPrinter.Text = Printer.DeviceName
When i click a button to get the index of the item in the dropdown box:
For i = 0 To cboPrinter.ListCount - 1
MsgBox cboPrinter.List(i) & cboPrinter.ListIndex
Next
it says the listindex for each item is -1. Shouldn't it be 1 to how many printers there are in the list ie:
printer 1 = index 1
printer 2 = index 2
etc?
Or is that method of setting the default printer wrong and interfering?
thanks for your time.
Recieving Item By Index
hi,
with this piece of code im trying to receive a certain record by stating the ID in the table.
i have a variable which stores the ID, intStaffID. but im not sure where to place it in the following code.
this is on the click event of an mshflexgrid. it stored the ID, then i want it to select the staff record with that ID...
Code:
If Not IsNull(myRecSet.Fields("shiftstartMon").Value) Then 'Validation for null value
strGetMonStart = myRecSet.Fields.Item("ShiftStartMon").Value 'Get data from field
txtShiftStartMon.Text = strGetMonStart 'Insert data to textbox
Else
txtShiftStartMon.Text = "No Shift" 'Insert "No Shift" If value = Null
End If
thanks,
sam
Index Of Selected Item
Anybody out there know a quick way for me to find out the index of a selected item within a listview?
I know I could loop through it easy enough to find the index but is there another way of doing it?
Api To Get The Index Of An Item In A ComboBox
Hi,
Is there any APi that give us the index of comboBox item? For instance, I would say the item as a tring and then the APi would tell me is index in the combo?
PS: I need this to get the index of a itemdata.
Thank you
Sergio Oliveira
How To Get The Item Index In Wmp.dll Control
hi, please if somebody can tell me how can i get the item index of a media item in a playlist in this control (wmpsdk 10 or 9)
i want to know the item index of the current media playing (maybe the same media is twice or more in a playlist in diferent position (index), so i can use isidentical)
thank you
Please Help - Error 457 - Index Already Associated With This Item.
Simple form used to input 2 strings (key & value), to be stored in Dictionary (dictLocations)which is instantiated in Module1. Works fine until user clicks yes in message box, then get Error 457 (duplicate key)???
Thanks for anyone's help!
private Sub cmdOK_Click()
Dim key as string, val as string
dictLocations.Add tbLocNo, tbLocDesc
If MsgBox("Add Another Location?", vbYesNo) = vbYes then
me.Hide
tbLocNo = ""
tbLocDesc = ""
me.Show
else
me.Hide
End If
Unload.me
End Sub
Getting The Index Of A Collection Item.
Is it possible to get the Index of a collection item if you know the key it was added under?
example:
dim Mycol as new collection
Mycol.Add "keyboard","bob"
Mycol.Add "monitor","peter"
Mycol.Add "desk","joe"
I want to know that "monitor" is the second item in the list by using the key "peter" can this be done?
Jean-Guy
Only Unknowns Get Added To My Report Listview.
hey guys I have a listview called report that get items added to it when items in my list6 are clicked.
Now items go in list6 with the code here.
VB Code:
lvwFound2.ListItems.ClearList1.ClearList6.ClearDim X As LongDim Y As Long'Dim intI As IntegerDim FindStr As StringDim i As Long Dim SearchPath As String Dim FileSize As Long Dim NumFiles As Long, NumDirs As Long Dim strParts() As String Dim lngIndex As Long Dim lngReturn As Long Dim strToFind As String Dim lngListIndex As Long'Dim strFT() As String'Dim FindStr As String'strFT = Split(Text2.Text, ",")'For intI = LBound(strFT) To UBound(strFT) ' FindStr = strFT(intI) ' FileSize = FindFilesAPI(SearchPath, FindStr, NumFiles, NumDirs) 'Dim strFT() As String'strFT = Split(Text2.Text, ",")'For intI = LBound(strFT) To UBound(strFT) ' FindStr = strFT(intI) ' FileSize = FindFilesAPI(SearchPath, FindStr, NumFiles, NumDirs)'scan.Showscan.Timer1.Enabled = Truescan.Label6.Caption = ".exe"Timer2.Enabled = TrueIf Text16.Text = "ON" ThenAttention.ShowAttention.Label1.Caption = "Autoscan is already engaged, you must turn off autoscan before running a single scan."Else: DoEvents Label19.Caption = "Scanning in progress... Please Wait." Text10.Text = Text10.Text & vbNewLine & "Scanning in progress...Please Wait.." 'Label7.Caption = "Last antivirus/process scan was at: " & Format(Now, "DD MMM YYYY hh:mm:ss") TerminateEXE Text2.Text If Text2.Text = "" Then Exit Sub End If For i = 0 To List1.ListCount - 1' put in your search here using List1.List(i) Next 'Text2.Text = "*.*" 'Screen.MousePointer = vbHourglass 'StatusBar1.Panels(1).Text = Label16.Caption List1.Clear SearchPath = Text1.Text FindStr = Text2.Text FileSize = FindFilesAPI(SearchPath, FindStr, NumFiles, NumDirs) ' StatusBar1.Panels(1).Text = Me.lvwFound.ListItems.Count & " Problems found." ' split' Dim xxx As String' lvwFound.ListItems.Add , , "what?" ' strParts = Split(xxx, "")' lvwFound.ListItems(1).SubItems(1) = strParts(UBound(strParts))' List5.AddItem = strParts(UBound(strParts)) ListFiles "C: emp", "*.txt" ' For i = 1 To 10 ' List1.AddItem "2"'NextDim ixi As Long'For ixi = 0 To List1.ListCount - 1 'If List1.List(i) Like "Update" Then List1.RemoveItem (ixi) 'Next ' All matching elements are removed. In this case, the list is cleared. 'atching elements are removed. In this case, the list is cleared. For lngIndex = 0 To List1.ListCount - 1 lvwFound2.ListItems.Add , , CStr(lngIndex + 1) strParts = Split(List1.List(lngIndex), "") lvwFound2.ListItems(lngIndex + 1).SubItems(1) = strParts(UBound(strParts)) Next For intI = 1 To lvwFound2.ListItems.Count strToFind = lvwFound2.ListItems(intI).SubItems(1) lngReturn = SendMessage(List2.hwnd, LB_FINDSTRINGEXACT, -1&, ByVal strToFind) If lngReturn >= 0 Then lngReturn = SendMessage(List6.hwnd, LB_FINDSTRINGEXACT, -1&, ByVal strToFind) If lngReturn = LB_ERR Then List6.AddItem strToFind Call LoadReportListview End If End If Next intI lngListIndex = SendMessage(List6.hwnd, LB_FINDSTRINGEXACT, -1, ByVal "NeroCheck.exe") If lngListIndex > -1 Then List6.RemoveItem lngListIndex End If ' add search resutlsinto lvwfoudn' lvwFound.ListItems.Count 1, , Me.List1.List(0), 0, 0' Me.lvwFound.ListItems.Add Me.lvwFound.ListItems.Count + 1, , Me.List1.List(3), 0, 0 ' labListCount.Caption = "Number of Detected Files Found: " & CStr(List6.ListCount) 'Text10.Text = Text10.Text & vbNewLine & "Scanning Complete, Results are below" ' Text10.Text = Text10.Text & vbNewLine & labListCount.Caption ' Label16.Caption = Text3.Text' List1.Clear lvwFound2.ListItems.Clear ''''' do it again+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+
And the subs I call are here.
Private Sub loadreport()
Dim itmXi As ListItem
Set itmXi = Report.ListItems.Add(, , Label15.Caption)
itmXi.SubItems(1) = Label34.Caption
itmXi.SubItems(2) = Label26.Caption
itmXi.SubItems(3) = Label32.Caption
itmXi.SubItems(4) = Label36.Caption
End Sub
and
VB Code:
Private Sub LoadReportListview()'Label26.Visible = FalseDim con As ADODB.ConnectionDim rs As ADODB.RecordsetDim strSQL As StringDim strCol As StringSet rs = New ADODB.Recordset'Set con = ADODB.ConnectionSet con = New ADODB.Connectioncon.CursorLocation = adUseClient con.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.path & "DatabaseMain12.mdb;" & "Jet OLEDB:Database Password=omegacron2;"strSQL = "Select NameOfItem, TypeofFile, Severity, Description From Table1 " & _"Where (VirusList = '" & Label15.Caption & "')"rs.Open strSQL, con, adOpenStatic, adLockOptimistic' then when your rs returns...If rs.EOF = True Then ' might also be able to check if rs.RecordCount=0 Label34.Caption = "Unknown" Label32.Caption = "Unknown" Else ' note: use of & vbNullString below prevents errors if a field is null rs.MoveFirst Label34.Caption = rs.Fields("NameOfItem") & vbNullString Label26.Caption = rs.Fields("TypeOfFile") & vbNullString Label36.Caption = rs.Fields("Description") & vbNullStringEnd Ifrs.CloseSet rs = Nothing If Label32.Caption = "" ThenLabel32.Caption = "Unknown"End If If Label15.Caption = "" ThenLabel15.Caption = "Unknown"End If If Label34.Caption = "" ThenLabel34.Caption = "Unknown"End If If Label36.Caption = "" ThenLabel36.Caption = "Unknown"End If If Label26.Caption = "" ThenLabel26.Caption = "Unknown"End If End Sub
But when the program runs and items get added to list6, only the word "unknown shows up in each of the report listview columsn.
Did I make some sort of big mistake?
thanks!
Getting Item Data Index With Listbox Value
I'm trying to get the itemdata int value from a listbox using the listbox text value. For example:
populate the listbox using a query:
rst = select id, value from table
While (Not (rs.EOF))
lstbox.AddItem rst!value
lstbox.ItemData(lstbox.ListCount - 1) = rst![id]
rstSiteID.MoveNext
Wend
So what i want to do is get the "id" value from a selected
"value" in a listbox.
Any help would be appreciated.
>> How To Determinate The Index Of An Item In Array
Hi! I have 2 arrays called "id()" and "name()" and when I assign a string value to the name array, I assign also an id.
so... i want to get the index by specifing the item in the "name" array like this:
1st item= "a" index = 0
2nd item = "b" index = 1
and if i want a function that determinate the index of an item by specifing the text in this case
thanks
simons
|