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
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
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.
Remove Item Index Number 1
Hello, I am making a list of people that connect to the chat room of there IP in a list called listPeople. But i want to remove the ip when they disconnect. I know the code is something like this, but can you help me get it right?
listPeople.removeitem(UserIP, [1])
UserIP being a String of thier remoteIP
and
1 being the index
also will the same code work with listpeople.additem?
Thanks in advance/.
Using The Index Number Of An Item In An Array
Another easy one (sorry!) :-)
I am trying to use the number of the items in my array so that, say:
If ArrayOne (Item number is 1 or 2 of array) Then
Do this
If ArrayOne (Item number is 3 or 4 of array) Then
Do this
Etc...
Is it possible?
Thanks for reading, Chloe x
Setting String As An Array Index Number
Trying to set a string the index number or an array. But I'm getting 0 every time
:wall:
Code:
Private Sub array_Click()
strName = array(i = 2).Index
MsgBox (strName) ' always gives zero
End Sub
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?
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
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.
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!!
Setting A ListView Item To An Id From The Database
I have a ListView control on form1 (frmAddItem). The ListView displays a recordset from the code = SELECT producer, producerId FROM producer. There is only one column in the ListView control and displays names of producers. Suppose I want to edit one of the selected producers from the list how can I set the producerId ? This is what I have
VB Code:
Private Sub cmdEdit_Click()With frmAddItem .Caption = .Caption & " Edit/Update Record - " & .txtItem .ListType = mListType .txtItem = Me.ListView1.SelectedItem.Text' The following line is what I need to set to correspond to the producerId .TheID = ListView1.SelectedItem.Index 'This line is not working. Brings producer name instead .cmdOk.Caption = "&Save" .cmdCancel.Caption = "&Cancel" .Show vbModal End WithEnd Sub
Thanks
Listview Item Number
I want to know what item in a listview I have clicked on:
Dim it As ListItem
Set it = ListView1.SelectedItem
but this code returns the item text, not the item number. What property do I have to look at?
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.
Setting Tab Index
Hi all!
I've been given the sub-assignment of making the UI "user-friendly" (whatever that means). I have a datagrid that is built on the fly (programmatically) and this datagrid has 4 columns and many rows.
I'm looking for a way to set the tab index for all of the columns/rows in the datagrid. Can someone help me with this? I can't seem to find how to set this property programmatically.
Thanks!
AMACycleLoony
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
Combo Box ,setting Index
i have a combo box,in dropdown list style,how can i set a default index,when it appears?
i tried something like cmbTop.index=1 is read only
i tried cmbTop.listindex=1 it gives me invalid property value
and it has 5 values inside(5,10,15,20,25) created in designer
so how can i set an item selection?
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
Calling An Item By Its Index In A Type
Let's say I have a Type like this:
VB Code:
Public Type userinfo()Name As StringPassword As StringEnd Type
Now, if I want to access the item "Name", I need to say
VB Code:
Dim i As userinfoMsgbox i.Name
Can't I access an item by its position or index like this:
VB Code:
Dim i As userinfoMsgbox i.Index(0)'The above code is not right but it gives you the idea.
?
Index Of Selected List Item
I have a combo box, style 1, where users can enter items into the list by typing it then hitting enter. I want the user to be able to select one of the list items already entered and be able to delete it by pressing the delete key.
How can I delete the selected record?
Selecting An Item From A DataCombo Using The Index ID
Good morning all. I have a DataCombo control (not to be confused with ComboBox) which is populated with data. I am wondering how I can display the Description (ListField) text by referencing the Index ID (BoundColumn) i.e.
I have three entries in the DataCombo
0. Red
1. Green
2. Blue
I want to reference which is to be shown by the number, but I want the string to be displayed.
How I Could Get The Index Adding An Item To A List?
The solution could be this :
List1.AddItem ("" , Index)
but, it does not work!!!
First i have a compiler error (expected = )...
Num = List1.AddItem ("" , Index) Solves the problem, but if index is diferent than 0 this doesnot work.
I want to create a dinamic list of errors and capture his identification.
How i could do this?
Setting Tab Index For Userform Elements
Hello all - I am working on a userform for an Excel template, and I want to set the tab indexes for each of the userform elements. However, I keep running into trouble because of the use of multiple frames on my userform.
I have taken a screen capture of the tab indexes I want each element to have, and I've attached my userform code, so that you can try it out and see what the tab indexes actually are right now.
I've set the tab indexes over and over again, but every time, they reset themselves when I click outside of the current frame.
Does anyone have any suggestions on how to set the tab indexes the way I want them? Is it possible to work in one frame, enter a sub-frame, and then go back out to the outer frame?
Setting The Index In A Combo Box At Run-Time
I have several combo boxes that I want to set at a certain index. Say index 0. This is probably really simple and I'm spacing out but can't figure out for the life of me how to do this. Thanks for your help!
jhwkgirl
Setting 1-dim. Arrays To 1st Index Of 2-dim. Array
I may just be brainfarting today, but I can't figure out a way to easily set a 1-dimension array to the first index of a 2-dimension dynamic array, i.e.
Code:
Dim l_dblDynamicArray()
Dim l_dblOneDimArray()
ReDim l_dblDynamicArray(2,100)
l_dblOneDimArray() = l_dblDynamicArray(1)
Note that variable types don't seem to matter. Also, I know I can easily loop through, but I am trying to clean up some code. There MUST be a way!
Setting An Index For Recordset Field
I am trying to set a specific field to an Index in my recordset so that I can retrieve the data in that specific order. Anyone know the syntax for doing that and then applying it.
Thanks
Setting Listbox Index To Long???
Is there anyway to set the listbox index property to return a long instead of a integer????
i can put more than 33 thoudsand entries in the listbox but i get an overflow error when i try to access one of the item past 33 thousand and whatever ( integer limit) .
thanks for your help.
Setting The List Index Of A Combo Box
I've done this many times, but for some reason it's not working this time. I load 2 combo boxes whos style property is 2-Drop down list. One from a recordset and the other is hard coded with 3 items in the Load event of the form. After the boxes are loaded I try to set them to a particular entry.
The load event of this form is fired from the double click event of a flex grid on another form. The first time thru the AREA combo box will change to the proper entry but the PRIORITY combo doesn't change at all.
I've put break points in the code on the lines where I'm setting the list index and the lines are being executed but nothing is changing. I've also setup a dummy routine in the form click event and scrolled the values in the combo boxes by clicking on the form. But I have no clue as to why they won't update as expected. Here is the Form Load event where the cbo boxes are.
CODEPrivate Sub Form_Load()
Dim sqlArea As String
Dim rsArea As ADODB.Recordset
Dim a, aa As Integer
'MsgBox "Load"
sqlArea = "Select Area from tblArea Order By Area"
Call OpenConnection
Set rsArea = New ADODB.Recordset
With rsArea
.Open sqlArea, conn, adOpenStatic, adLockReadOnly, adCmdText
End With
'Load the area combo box
cboArea.AddItem "", 0
Do Until rsArea.EOF
cboArea.AddItem rsArea.Fields("Area")
rsArea.MoveNext
Loop
cboArea.Refresh
cboPriority.AddItem "1-High", 0
cboPriority.AddItem "2-Med", 1
cboPriority.AddItem "3-Low", 2
cboPriority.Refresh
txtOwner = "Product Engineer" 'default
rsArea.Close
Set rsArea = Nothing
'================================================================================
'load the data from the flex grid to the form
'"Problem|Area|Owner|^Priority|Input Date|^Close By|Date Closed|^On Report|EnteredBy|ActionComments"
' 0 1 2 3 4 5 6 7 8 9
With frmMain.FlexActions
txtProblem = .TextMatrix(.RowSel, 0)
'area
For a = 0 To cboArea.ListCount - 1
If .TextMatrix(.RowSel, 1) = cboArea.List(a) Then
frmEditAction.cboArea.ListIndex = a
Exit For
End If
Next a
txtOwner = .TextMatrix(.RowSel, 2)
'priority
For aa = 0 To cboPriority.ListCount - 1
If .TextMatrix(.RowSel, 3) = cboPriority.List(aa) Then
frmEditAction.cboArea.ListIndex = aa
frmEditAction.Refresh
Exit For
End If
Next aa
DTPCloseBy.Value = .TextMatrix(.RowSel, 5)
txtActionComment = .TextMatrix(.RowSel, 9)
End With
End Sub
Setting TabStrip Index Via Code
I need help with how to set the tab that needs the focus via code. I have a TabStrip with 4 tabs, and I'm using this sub to control the strip when clicked, but how can I send the sub an Index number via code, I need a certain tab displayed automatically (tried: TabStrip1.SelectedItem.Index = A%, but it is read only)
Private Sub DoTabLogic()
Dim iCurrTab As Integer
iCurrTab = TabStrip1.SelectedItem.Index
Select Case iCurrTab
Case 1
Frame1(0).Visible = True
Frame1(1).Visible = False
Frame1(2).Visible = False
Frame1(3).Visible = False
Case 2
Frame1(0).Visible = False
Frame1(1).Visible = True
Frame1(2).Visible = False
Frame1(3).Visible = False
Case 3
Frame1(0).Visible = False
Frame1(1).Visible = False
Frame1(2).Visible = True
Frame1(3).Visible = False
Case 4
Frame1(0).Visible = False
Frame1(1).Visible = False
Frame1(2).Visible = False
Frame1(3).Visible = True
End Select
End Sub
Thanks
Catrina
How Can We Know The Index Of An Item Data Value In A DropDownList Combo In VB6
I would like to receive help on the following described issue.
In my form I have a dropdown list combobox, which is populated with 'additem' and 'Itemdata' methods. during program execution, I know only a particular value stored in the itemdata. I dont know index and listed values.
I want to get the index corresponding to the Itemdata Value. How can i get that?
Thanking everybody,
sreeraj
Finding The Index Of A Control Array Item
Hey im really new with VB,
I have a control array in my project and i need to find out which element in the array the user clicked on.
Just to clarify, say theres 5 elements in the array
option(1), option(2), option(3), option(4), option (5)
when the user clicks on any of these i need to assign the number in the index, (1,2,3,4 or 5) to a variable. Thanks a lot!
List Box Q, Remove An Item, By Value Not Index? *solved*
Is there an easy method to remove an item from a list box, if there is more then say, one item in the list for a particular Value etc?
Say i have a list:
Wayne
Joe
Fred
Bob
Fred
And my server sends the message to the client "Remove Fred", (I have this bit working ),
How can i remove both "Fred"'s without knowing their ListIndex's?
Tnx
Get Handle On File Via Numeric (item) Index
Hi there,
First time poster...
I'm using VBA in Office 2003 Excel and am trying to get a handle on a file via a numeric index. Basically i have a folder containing some 527 files and need to loop thru them all and process them.
so I am trying to do something like this but it's not working - anyone know what i'm doing wrong?
Set fs = CreateObject("Scripting.FileSystemObject")
Set f4 = fs.getfolder(Path_str).files.Item(1) <== fails
I have previously tried a for...each loop without success - the loop exits unexpectedly after processing the 132nd item. Have attempted processing the item in question using a smaller set of data (ie when the folder only contained 5 items, the item in question was in the middle of the 5 files) and the macro was able to process and continue to the next item successfully. So believe that it's not related to the content of the file itself.
Is there some kind of limit to the number of items a variable can hold in VBA? When I step thru the code, the loop dies as soon as I try to step thru the "Next f3" statement.
Here's my code, if anyone can spot what might be causing the issue then please let me know:
Dim fs, f, f1, f2, f3, fc, fd, fe As Object
[...snip...]
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.getfolder(QARunEnvPath_str)
Set fc = f.subfolders
[...snip...]
'
' Get a handle on Business Function subfolders and start loop
'
For Each f1 In fc
'
' Create a copy of the Test Data Folder using the DIR suffix string
'
NewFldr_str = f1.Path & cDIR_SUFFIX
fs.Copyfolder f1.Path, NewFldr_str
'
' Get handle on files within new folder, then start looping thru those
'
Set f4 = fs.getfolder(NewFldr_str)
Set fe = f4.Files
For Each f3 In fe
[Do stuff....]
Next f3 ' Next File
Thanks in advance
Trouble Setting User ID As Index For Winsock
well I am trying to set an ID in the user database and make the ID the users connections Index. I cant realy explain the problem that greta so I'll send the code over. Theres a problem in the Connection Request and the AddNewUser in UserDB mod i believe.
Setting Combobox OnLoad To Specific Index
I have a vb form that, after a user selects items in two different comboboxes, I load the reast of the form with data from MSDE.
But I have 2 other comboboxes that I need to set to a selection. The comboboxes are loaded with the selections, but I need to have the code select a specific itemdata.
Just to show how lost I am:
Code:
'Me.cboAdvertiser.ItemData
Me.cboAdvertiser.ListIndex = Me.cboAdvertiser.ItemData(Me.cboAdvertiser.ListIndex)
If it was just the index value, it would be easier, but I need to combobox to be set to the correct itemData. So I guess I need to somehow convert the itemdata to an index value? It seemed alot easier in Access, but it looks like the same property isnt available in VB?
|