Listbox Moving Listindex
i have this code to select the next listindex and if its at the end start at the beggining again.
VB Code: List1.ListIndex = (List1.ListIndex + 1) Mod List1.ListCount
my question is can anybody come up with a line like that but make it go backwards. i know you can do if statements to check where the index is but i have been trying to figure this out and i just cant get it right.
thank you. casey.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Listbox's ListIndex
How can I make the listindex method of a listbox to return a long value? By default it returns an integer value.
I remember seeing a code here for transforming an integer with - in a long... or is there another method for doing this?
Listbox Listindex
i found this, it moves the listindex down one each time i press the button and when it gets to the bottom of the listbox it goes back to the top.
List1.ListIndex = (List1.ListIndex + 1) Mod List1.ListCount
how could you change that to make it go up instead of down.
thank you.
ListBox ListIndex = -1
I've got a listbox (lstLeft) that stores 10 possible values. I've got a recordset that returns those that match for the corresponding agent. So I might have one that matches and I might have more.
I'm trying to write code that will loop through the ItemData of the items in lstLeft, if it matches, move the item from lstLeft to lstRight, so that all matching values for the selected agent will appear when I edit his/her file.
Problem is, my ListIndex value keeps coming up with a value of -1. My code is shown below...any thoughts? Is there a better way to tackle what I'm trying to accomplish?
Do While Not objRS.EOF
If lstLeft.ItemData(i) = objRS("ID") Then
lstRight.AddItem lstLeft.Text
lstRight.ItemData(lstRight.NewIndex) = lstLeft.ItemData(i)
lstLeft.RemoveItem lstLeft.ListIndex
Else
i = i + 1
End If
Loop
Getting The Listindex In A Listbox
Getting the listindex in a listbox, without knowing what the position of chosen item.
For ex. I have a name that is in a listbox (which is not visiable). The user types a name into a textbox. Is there a way to get its listindex?
ListBox Listindex?
I have a ListBox with MultiSelect property set to 2-Extended. In VB6 runtime, how can I clear the selection?
Listbox, Listindex, Array
Hi,
I am relatively new to programming and hoping for some pointers on how to represent this little problem in code
.
I have 2 list boxes L1 and L2 containing the following text and variables which can change with each new calculation
L1...........L2
A
3
A
1
B
5
A
4
B
4
In L1, A corresponds to 3 + 1 + 4 = 8 from L2
In L2, B corresponds to 5 + 4 = 9 from L2
Since 9 > 8, B appears in a textbox, txt1.
The maximum number of rows in listboxs will be 10 at any one time.
I hope someone out there can help
..Thank you
Listbox Listindex Array
Hi there,
im not sure how to get the listindex in my array in the first sub, thats all i gotta do to finish this off.
and also just curios, if i used TIME to timestamp each history/msg when i addhistory it seems to make the listbox flicker more, can i prevent that.
'gather history and send to index user.
Code:
Sub GetHistory(Index As Integer, Msg As String)
Dim a As Integer
For a = 0 To List1.ListCount - 1
End Sub
Public Sub AddHistory(Msg As String)
On Error Resume Next
Dim a As Integer
List1.AddItem Msg, 0
If List1.ListCount = 11 Then
List1.RemoveItem 10
End If
End Sub
Listbox...listIndex.. .ItemData ???
Been awhile since i've been in vb6 and have run into an issue. I have a combo box that i have populated using a recordset. What i'm trying to do, is to select the value in the combo box based off of an ID i have.
So basically, if i have the ID 17 from a database.. i want the cbo text to say 'Ron'... how do i do this?
I tried to search... but couldn't find it.
Thanks
Code:
List Index ItemData Text
0 1 John
1 11 Shawn
2 17 Ron
3 19 Don
Listbox Listindex Problem
I have a listbox that I populate, assigning index numbers to each such as:
Code:
SortList.AddItem "Employee Name", 0
SortList.AddItem "CardID", 1
SortList.AddItem rs!Comp_Info1, 2
SortList.AddItem rs!Comp_Info2, 3
What I want to do is have the listbox be filled based upon a query from a database, so I may have "Employee Name" and "rs!Comp_Info2" in the listbox or I may not.
After the user selects a list item I need to find out which one they have selected, but I cannot do that by the list.text because I don't always know what the list.text will be. That is why I am currently using the listindex.
The problem I have run into is that if I try to add this to the sortlist:
Code:
SortList.AddItem "Employee Name", 0
SortList.AddItem rs!Comp_Info1, 2
I get an error, which I presume is because the listindex is not sequential. Is there anyway I can make this listindex work, or is there any other way to reference a list item besides the item text?
Thanks,
B
Set Listbox Listindex To Text
I have Text1 and List1. I want to set the Listbox Listindex to the text in Text1 instead of the Listindex number. In other words, if Text1 = "Cats" then the List1 Selected item would go to Cats.
Thanks
Listbox (listindex Problem)
i have 2 form. form 1 has listbox and 2 commandbuttons and form 2 has prograssbar and timer control and labelbox. i am adding 6 or more files in listbox and i am selecting file then click on button it showing 2 form and prograssbar is working and when prograssbar rich end the label says 100 % done. The problem is when it will done with first file it will select 2 file from listbox and start doing same thing so user do not have to select the file and click the button.
i konw it's confius but if any one can help me that will be great. Thanks
Search Listbox & Return Listindex
I need to search a listbox for a certain string value and return the listindex value (I will later remove the item at that listindex location - but I already know how to do that). How would I go about this?
Highlight Listbox Row Without Listindex Method?
I'm looking for a way to highlight a listbox row (In checkbox style) without using the .listindex method.
Listindex causes the CheckItem_event to fire and the check to toggle.
I'm using the MouseMove event and the API to determine which row the mouse cursor is over. Just need someway to highlight the row for user feedback.
Thanks,
~T
Retrieving ListBox' ListIndex By A Partial String. Please Help..
Hi,
Can somebody help pls.. I have a ListBox and a TextBox. What I need to figure out is, let's assume that the Listbox contains:
vb Code:
Private Sub Form_Load()With List1 .AddItem "Chocolate" .AddItem "Fruits" .AddItem "Electronics" .AddItem "Liquid" .AddItem "Magnetics"End Sub
And the TextBox is used to find any String contained in the Listbox (but it would find any sting in the listbox even in 'Partial') and then when the string is match, the ListIndex on which the item is stand will be retrieved..
wow, hopefully this is understandable
For example:
In the textbox I type: "ics"
then the the listbox will reload its items according to the text typed.
When I type "ics" in means Electronics and Magnetics item will be the only items that would be re-loaded. So that's what I mean with "Partial words"
So how should I do that ?? Thanks alot..
MyArray Populate A Listbox - Get Listindex Number
there are 20 rows and 3 columns which populate a listbox..
strGetName = MyArray(intNum, 3)
(now strgetname = "1, employeesname, n" - this is what shows up in the list box)
how do i get the ListIndex of the strGetName?
thanks,
- Gabe
Listbox To Listbox File Moving
I am working on an application where I want to present a current file's field list in one listbox and let the user Click once to highlight it and click a command button to move it from that listbox to another one (for processing). When moved I want it to be gone from the first list and present in the second. Similarly, I have another command button that does the opposite. Can someone give me some ideas of how I actually do this?
Moving Listbox??!!
ok, how do i make an item in a listbox (List1) move into another listbox (List2) after i have selected the item and the pressed a command button. For example: In listbox1 i have an item that says "Hello" then i select it and click the command button then "Hello" moves it from listbox1 into listbox2 and is no longer in listbox1 any more. How do i do this please help!!
Thank You.
Moving From One Listbox To Another
I am currently moving items from one listbox to another the normal way with a loop. However, there can be up to 15,000 records that are moved at one time. Is there an API call that will move all records from one listbox to the other more quickly and efficiently?
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 Item From One Listbox To Another
Hey all
I am trying to move an item from one listbox to another. The first listbox has items where the RowSourceType = "Field List" and the second one is value list. This is my code:
Private Sub DisplayAllFields_DblClick(Cancel As Integer)
If ListOfFieldsSelected.RowSource = (List0.Value & "." & DisplayAllFields.Value) Then
MsgBox ("You cannot select a field more than once. Please select another field")
Else
ListOfFieldsSelected.AddItem (List0.Value & "." & DisplayAllFields.Value)
End If
End Sub
When I double click the same value in the first list again, it brings up the msgbox once but it doesn't do that once it has added another field to ListOfFieldsSelected. I would use the RemoveItem method so user can't click the field again but DisplayAllFields is set to Field List so it can't remove item unless set to "Value list". Any suggestions on this?
Any help will be greatly appreciated.
Many thanks
Rupa
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 Listbox View
After picking an item in a Listbox, I want to return it to the top of the list. using listindex just selects an item, but doesn't return whats shown to that item. I want it to display item 0.
How do I accomplish this?
I had:
Code:
ListBox1.ListIndex = 0
but it just highlights the item, but does not show it.
i'm showing one item at a time, and scrolling to the picked item.
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!
ListBox, Moving From First Item To Second And So On
Hey, im working on a media player, the media player works great but the playlist is screwey! Im having troubble with this:
You select an item for play - 100% ok
it plays it - 100% ok
it then goes to the next item on the list - BUGGY!
it wont move to the next item and when it does, it wont update the selected item eg, it will play the next item then when thats done it will play the one before that not the next on (constant loop between two files). Please help
Moving Items In Listbox Down
This code is supposed to move items down 1 spot within the list box with the push of a cmdbutton. I got it to move one item at a time down, but ideally it should move multiple items down at the same time. Any ideas or suggestions would be greatly appreciated. Thank you.
Private Sub cmddown_Click()
Dim Temp As String, Item As Integer
Item = lstShopping.ListIndex
If (Item > -1) And (Item < lstShopping.ListCount - 1) Then
Temp = lstShopping.List(Item)
lstShopping.RemoveItem Item
lstShopping.AddItem Temp, Item + 1
lstShopping.ListIndex = Item + 1
End If
End Sub
Archie Kantzavelos
Moving ListBox To Typing Position.
Hey,
I have a question for you that seems to me as if it could be a hard one... I have not been able to find anything about it, mainly because I haven't got a clue as to where to look for...
I made some sort of AutoComplete feature in my program (in a RichTextBox), and it would be really nice if I could make it similar to Visual Basic's "Auto List Members" option (which is the listbox popping up with possible keywords when you type a ".")
I want a ListBox to become visible whenever the program is autocompleting a word, that lists all other possible keywords (because there are often multiple).
I want this ListBox to appear at the location of the I-beam (selection thingy).
How can I get it to move there? Is it possible to find the Top and Left location of the I-beam inside a RichTextBox somehow? I doubt it...
Can it be done otherwise?
Moving Listbox Items W/ Mouse
does anyone know how to shift listbox items around with the mouse? a good example would be winamp's playlist. the code i came up with works fine...if you move your mouse slowly. if you go fast, it'll pretty much mess up the order because the cursor jumps around when you move your mouse too quickly.
Dim HotItem1 As Integer
Private Sub List1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
If HotItem1 <> List1.ListIndex Then
If HotItem1 > -1 Then
a = List1.List(HotItem1)
b = List1
List1.List(List1.ListIndex) = a
List1.List(HotItem1) = b
End If
HotItem1 = List1.ListIndex
List1_Click
End If
Else
HotItem1 = -1
End If
End Sub
Moving Text From Textbox To Listbox
I'm trying to move text from a multiline textbox [Text1] to a list box [List1] but I cant seem to get it :-( Here's what I've done so far.... The code skips some lines. Any help will be appreciated. TIA
Dim CurrStart As Integer
Dim Temp As String 'temp buffer
CurrStart = 1
Temp = Text1 'save text1 to temp
While InStr(CurrStart, Temp, vbCr)
CurrStart = InStr(CurrStart, Temp, vbCr) 'find the newline
List1.AddItem Left(Temp, CurrStart) 'add this line to listbox
Temp = Right(Temp, Len(Temp) - CurrStart) 'remove this line from temp
Wend
When Moving Item Down In The Listbox The Text Disappears
Okay dont know why but the text is dissapearing when an item is moved down the list box.
Image1 displays before the move down
Image2 displays after the move down
Code is also attached. I am very confused I have been through this code througherly and I am sure there is not an error in the code.
Code:
' check: only proceed if there is a selected item
' check: last item can't be moved down
' save items text and items indexvalue
' remove item
' place item back on new position
' if you keep that item selected
' you can keep moving it by pressing cmdDown
' for arLoopCount adds the new playlist entrys from
' lstPlayList.
' list1 refreshes
' lstPlayList refreshes
Dim tempStr As String
Dim iIndex As Integer
Dim arLoopCount As Integer
List1.Clear ' Debugging orriented object to display the contents of arFilePlayList Array
If lstPlayList.SelCount = 1 Then
If lstPlayList.ListCount - 1 = lstPlayList.ListIndex Then
Exit Sub
Else
tempStr = lstPlayList.List(List1.ListIndex)
iIndex = lstPlayList.ListIndex
lstPlayList.RemoveItem lstPlayList.ListIndex
lstPlayList.AddItem tempStr, iIndex + 1
lstPlayList.Selected(iIndex + 1) = True
End If
End If
For arLoopCount = 0 To lstPlayList.ListCount
arFilePlayList(arLoopCount) = lstPlayList.List(arLoopCount)
List1.AddItem arFilePlayList(arLoopCount)
Next arLoopCount
List1.Refresh
lstPlayList.Refresh
Problem Moving Listbox Horizontal Lisbox Scroller To The Right
Hi all i put a horizantal scroller for mylistbox but unfortuntally i can not use it sicne i have long data in my listbox and i can not move the tab for the horizantal listbox since the with of is big enought that does not allow any movment to right side!! Even if i try to make my listbox width big still i face problem. Is there a way to make the size of scroller tab smaller so i can move it to the right side ? I hope some one help me here.Thanks
VB Code:
Private Declare Function ShowScrollBar Lib "user32" (ByVal hwnd As Long, ByVal wBar As Long, _ByVal bShow As Long) As LongPrivate Const SB_HORIZONTAL = 0
Dragdrop Moving Wrong Item In Listbox(aborted Dragdrop Idea)
I am using dragdrop in a list box(checkbox style) to move items around but sometimes it picks up the item below the one I selected instead of the one I clicked on. ANy ideas? heres the code I'm using
Code:
Private Sub lstFields_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If (Button And vbLeftButton) = vbLeftButton Then
nDragIndex = Y Me.TextHeight("Xyz")
If nDragIndex >= 0 And nDragIndex < lstFields.ListCount Then
blnDraging = True
End If
End If
End Sub
Private Sub lstFields_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim nIndex As Integer
Dim sItem As String
If (Button And vbLeftButton) = vbLeftButton Then
If blnDraging = True Then
nIndex = Y Me.TextHeight("Xyz")
If nIndex > lstFields.ListCount - 1 Then
nIndex = lstFields.ListCount
ElseIf nIndex < 0 Then
nIndex = 0
End If
If nIndex <> nDragIndex Then
sItem = lstFields.List(nDragIndex)
lstFields.RemoveItem nDragIndex
lstFields.AddItem sItem, nIndex
End If
End If
blnDraging = False
End If
End Sub
This is my first post with code in it so I hope I did it right, sorry if I didn't.
Sunflower Queen
Code For Moving To The First Blank Cell In A Worksheet; Moving Left,right,up Or Down
I have created an application form as a userform in Excel. I need to send the data entered into my text boxes when the program runs to separate excel cells in a worksheet.
My problem is I can use code that will send the textbox entry to a specific cell eg. If my textbox is named Surname I can say
range("a5").value = surname but if I do that when I run the programme to enter the next record for someone else the first record will be overwritten.
I NEED A CODE LINE THAT WILL TAKE ME TO THE FIRST EMPTY CELL AND ALLOW ME TO MOVE DOWN OR TO THE LEFT OR TO THE RIGHT
Listindex
I'm not able to retrive value by use of Listindex.
I get error code Expected end of statement.
Code:
Private Sub ComboBox2_DropButtonClick()
Dim z As String
Sheets("Sheet1").Activate
ComboBox2.RowSource = "C2:C9"
z = ComboBox2.ListIndex, 2
MsgBox z
End Sub
Some help ?
Thanks.
ListIndex
How would I make an Item in a listbox that contains a certain word the ListIndex?
ListIndex?
Hello all. I have a list box and a command button. I want to highlight an item in the list box then click the command button and it will open a certain site? How do I do this? Thanks in advance I really appreciate the help :>)
Need Help With ListIndex
I'm trying to take the ListIndex value of one List and assign it to another. The code I have is :
intIndex = Val(lstMain.ListIndex)
lstCDArtist.ListIndex = Val(intIndex)
Ive also tried:
lstCDArtist.ListIndex = Val(lstMain.ListIndex)
and:
lstCDArtist.ListIndex = intIndex
but it still gives me an error. How can I make this work?
Listindex
if i was to use this to make the listindex run backwards to the beggining of the list.(thats if the listindex is over 0)
Code:
For x = List1.ListIndex To 0 Step -1
List1.ListIndex = x
Next x
how would i make it stop at a certain text in one of the lists.
thanks
thingimijig.
Listindex
trying to loop through selections from a listbox and show the ID, only shows last selected entry...
Filling the listbox......
Code:
xml.Load DataPath & "clients.xml"
lst.Clear
Set xmlNodes = xml.firstChild
If xmlNodes Is Nothing Then
xml.loadXML "<Clients />"
End If
Set xmlNodes = xml.firstChild
XSLstr = "<xsl:stylesheet xmlns:xsl=""http://www.w3.org/1999/XSL/Transform"" version=""1.0"">"
XSLstr = XSLstr & "<xsl:template match=""Clients"">"
XSLstr = XSLstr & "<Clients>"
XSLstr = XSLstr & "<xsl:for-each select=""Client"">"
XSLstr = XSLstr & "<xsl:sort select=""Field[@Name='LastName']"" order=""ascending"" />"
XSLstr = XSLstr & "<Client>"
XSLstr = XSLstr & "<xsl:attribute name=""id"">"
XSLstr = XSLstr & "<xsl:value-of select=""@id"" />"
XSLstr = XSLstr & "</xsl:attribute>"
XSLstr = XSLstr & "<Field Name=""LastName"">"
XSLstr = XSLstr & "<xsl:value-of select=""Field[@Name='LastName']""/>"
XSLstr = XSLstr & "</Field>"
XSLstr = XSLstr & "<Field Name=""FirstName"">"
XSLstr = XSLstr & "<xsl:value-of select=""Field[@Name='FirstName']""/>"
XSLstr = XSLstr & "</Field>"
XSLstr = XSLstr & "<Field Name=""Address"">"
XSLstr = XSLstr & "<xsl:value-of select=""Field[@Name='Address']""/>"
XSLstr = XSLstr & "</Field>"
XSLstr = XSLstr & "<Field Name=""Phone1"">"
XSLstr = XSLstr & "<xsl:value-of select=""Field[@Name='Phone1']""/>"
XSLstr = XSLstr & "</Field>"
XSLstr = XSLstr & "<Field Name=""Phone2"">"
XSLstr = XSLstr & "<xsl:value-of select=""Field[@Name='Phone2']""/>"
XSLstr = XSLstr & "</Field>"
XSLstr = XSLstr & "</Client>"
XSLstr = XSLstr & "</xsl:for-each>"
XSLstr = XSLstr & "</Clients>"
XSLstr = XSLstr & "</xsl:template>"
XSLstr = XSLstr & "</xsl:stylesheet>"
XSL.loadXML XSLstr
Set xslNode = XSL.firstChild
XSLstr = xmlNodes.transformNode(xslNode)
xml.loadXML XSLstr
Set xmlNodes = xml.selectSingleNode("Clients")
If Not xmlNodes Is Nothing Then
For Each xmlNode In xmlNodes.childNodes
Count = 1
For X = 0 To lst.ListCount - 1
If lst.List(X) = xmlNode.selectSingleNode("Field[@Name='LastName']").Text _
& ", " & xmlNode.selectSingleNode("Field[@Name='FirstName']").Text Then
Count = Count + 1
End If
Next X
If Count = 1 Then
lst.AddItem xmlNode.selectSingleNode("Field[@Name='LastName']").Text _
& ", " & xmlNode.selectSingleNode("Field[@Name='FirstName']").Text
Else
lst.AddItem xmlNode.selectSingleNode("Field[@Name='LastName']").Text _
& ", " & xmlNode.selectSingleNode("Field[@Name='FirstName']").Text & "(" & Count & ")"
End If
lst.ItemData(lst.NewIndex) = xmlNode.Attributes(0).Text
Next
Else
End If
Looping though the selected entries..
Code:
For i = 0 To lstClients.ListCount - 1
ID = 0
If lstClients.Selected(i) Then
ID = lstClients.ItemData(lstClients.ListIndex)
MsgBox ID
End If
Next i
ListIndex
I have a form that displays several comboboxes. This works just fine. However, I want to have the box positions highlighted using data read in prior to going to this form. I, also have a lstlist.gotfocus so that when the user clicks on a list I can get the new positon.
I cannot figure out how to load a list and have a previous position highlighted without the program firing my lstList.gotfocus as it loads and screwing up my progam.
Help will ge greatly appreciated ...
How To Get Listindex...
SOmeone answered this a while back and I cannot find the thread...
But basically I have a combo box that uses say the following data
GM
Ford
DCX
Those are the values shown....however I have a check box where I assign the actual text to the combo boxes but the .ListIndex property always gets set to -1 .. no matter what I set it to...
for instance I may have a recordset which I pull back to set a value in the combo box:
Me.cboBox.Text = objRS("SomeField").Value
It sets the text in the combo box but listindex is still -1.
How can I ensure the listindex gets set properly ?
Thanks
Listindex
if i was to use this to make the listindex run backwards to the beggining of the list.(thats if the listindex is over 0)
--------------------------------------------------------------------------------
For x = List1.ListIndex To 0 Step -1
List1.ListIndex = x
Next x
--------------------------------------------------------------------------------
how would i make it stop at a certain text in one of the lists.
thanks
thingimijig.
ListIndex
Hello all. I have a list box and a command button. I want to highlight an item in the list box then click the command button and it will open a certain site? How do I do this? Thanks in advance I really appreciate the help :>)
ListIndex
Hi Everyone,
I am using ListView(ReportView) in my project, how can i check if the user has selected a rows. For example i can check if a list box is selected by doing if list1.listindex=-1 then msgbox "Not selected"
How can i do the same thing, so that the user has to selec on row from a listview.
thanks again
|