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




Combine List Items To Create New Item In Same List?


Hi all,

This has been giving me fits for a few days - any help would be most appreciated. I'm sure it's pretty simple, but I'm new to VB (and programming in general) and can't seem to come up with the correct syntax to get this to work:

I have a listbox from which the user can select mutliple items. Once user performs a multi-select, I enable a button (no problem there). When user clicks that button, I want to create a new item in that same list consisting of all selected items with "AND" between them.

Thus, if user had selected <item 1>, <item 2>, and <item 4>, the new item would be "<item 1> AND <item 2> AND <item 4>". Can someone please help me with the logic and syntax on this?

Here's what I have up to this point (I've removed the parts that I believe - based on the fact that this is not working - to be wrong and replaced them with ?????):

Code:
        Dim terms As String
        For Each terms In List.SelectedItems
            If List.SelectedItems.Count > 1 Then
                terms = ??????? & " AND " & ???????
            End If
        Next
        List.Items.Add (???????)


Thanks!!



Edited by - troy_atl on 10/17/2005 12:04:26 PM




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Create List Of Files From Folder But Allow Double Click On List Item To Run Bat
I am a newbie
But am making some progress
My next plan is to make a simple dialog with a list box and 3 buttons to do the following
List all the batch files in a folder
then allow me to highlight one item in the list so when I click the button it will run that bat file.

Sounds easy enough but I just keep hitting a brick wall and am not making any progress at all.

All help or similar snipits of code that I can re-organise will be greatfully apperciated.

Thanks in advance

Compare Item To List Of Items
In SQL, you can do:


VB Code:
SELECT * FROM IM WHERE IM_KEY IN (Jeremy,Josh,John)


Is there anything similar to this in VB so I can say:


VB Code:
If variable is in (Item, Item2,Item3) Then...Else...End If


Thanks, Jeremy

Loop The Loop: Adding List Item And Sub-items Assigned To Items.
Hello there,

below are the codes i've written to record all the items (which are qnsID) in list box (List1) into qnsdata_table.


Code:
Private Sub Command6_Click()
Dim x As Integer
Dim y As Integer

x = List1.ListCount
y = 0

rst.Open "SELECT * from qnsdata_table", cn, adOpenDynamic, adLockOptimistic

Do While Not y = x
rst1.Open "SELECT qnsdataID from autonumber", cn, adOpenDynamic, adLockOptimistic
rst.AddNew
rst!qnsDataID = "qd" & Right("000000" & CStr(CInt(rst1!qnsDataID) + 1), 6)
rst!qnsID = Me.List1.ItemData(y)
rst.Update
rst1.Close
rst1.Open "UPDATE autonumber SET qnsdataID = qnsdataID +1", cn, adOpenDynamic, adLockOptimistic
y = y + 1
Loop

rst.Close
End Sub


The problem is that for each item (qnsID) there are several assigned (ansID) and i need them to be recorded along with the qnsID, into qnsdata_table.
______________________________
| qnsdataID | qnsID | ansID |
-----------------------------------
| qd0001 | qns0002 | ans0012 |
| qd0002 | qns0002 | ans0016 |
| qd0003 | qns0002 | ans0001 |
------------------------------------

In this case, should i have another Do While Loop within the current Loop, to find out how many 'ansID' there are which are assigned to each 'qnsID'.

I've tried


Code:
rst2.Open "SELECT Count(ansID) AS ansID_count FROM ans_table where....(conditions)

Me.Text2 = rst2!ansID_count '(ive no idea where to store the count) value)

a = Me.Text2 '(shift value into variable a)
b = 0
and here goes another loop, but it didn't work.

Need some advice and comments from you guys =)

Thanks a million.

Astrov

How Can You Create A List That Contains All Items That Are Bolded In A Webbrowser?
For example..

if the webbrowser contains:
<b>Hello</B><font...><a href = "blah blah"></a><B>Test<a href=www.download.com></a></b>

then the listbox will contain
Hello
Test<a href=www.download.com></a>


and any more areas that are bolded..

anyone know how to do this?

Does Any Body Know How To Automaticly Create An Item In A List View
I Need To Know How To Automaticly Create An Item (With An Icon) In A List View with a command click Instead of already having an item there PLEASE RESPOND OR EMAIL ME HERE

Does Any Body Know How To Automaticly Create An Item In A List View
I Need To Know How To Automaticly Create An Item (With An Icon) In A List View with a command click Instead of already having an item there. PLEASE RESPOND OR EMAIL ME HERE

LIST BOX HELL. Please Save, Remove Items, Many List Boxes...one Last Name
ok, so the code so far, or as much as you need to see, is
****************************
***************************
***************************
***************************
***************************

Sub LoadCal()
Dim gdtDate As Date
Dim i As Integer
Dim x As Integer
Dim startDay As Integer
Dim giMaxDays As Integer

' clear list boxes before filling again
For i = 0 To 41
List1(i).Clear
Next

' * * * * * * * * * * * * * * * * * * * * * *
' * * * * * ADD DAY NUMBERS * * * * *
'label at top of form
Label1.Caption = MonthName(giMonth) & " " & giYear

'this is the current date
gdtDate = CDate(giMonth & "/01/" & giYear)

'minus one so the first line is never completely empty
startDay = Weekday(gdtDate) - 1

'the number of days in this month
giMaxDays = Day(DateAdd("m", 1, gdtDate) - 1)

'populates list boxes with days
x = 1
i = startDay
While i < (giMaxDays + startDay)
List1(i).AddItem (x)
x = x + 1
i = i + 1
Wend

' * * * * * * * * * * * * * * * * * * * * * *
' * * * * * ADD NAMES TO DAYS * * * * *

' !!!!!!!!!!!!!!!!!check to see that list is not empty !!!!!!!!!!!
If lstAgentList.ListCount = 0 Then GoTo done
'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

'agent list counter, "at which item" index
x = -1
'populate list boxes from the first day of the month with numbers
i = startDay
'counter for number of days until sunday
a = startDay - 1

'from the first day to the last day
While i < (giMaxDays + startDay)
If a < 6 Then
'a maximum of 3 names per day
While (List1(i).ListCount) < 4
' if there are no more items in the items list ('x' is greater than counter)
If x < (lstAgentList.ListCount - 1) Then
x = x + 1
' otherwise set it back to 0 (zero)
Else
x = 0
End If
'add the next name from the established agent list
List1(i).AddItem (lstAgentList.List(x))
Wend
a = a + 1
Else
'a maximum of 3 names per day
While (List1(i).ListCount) < 4
'add the next name from the established agent list
List1(i).AddItem (lstAgentList.List(x))
'here we do not increment name for it is a sunday
Wend
'reset 7 days until sunday counter
a = 0
End If
'increment day count
i = i + 1
Wend

done:
' end
End Sub



***************************
***************************
***************************
***************************
now see the shaddy thing with this is...well, it's a calendar month see, and every day is a list box....first item, the date, 1st, 2nd, 3rd, 4th, and so on...each list box can hold that first item, the date, plus 3 names.

if someone double clicks on one of those names (which are populated through other methods...not important) i want that name to be deleted...now where i am out of ideas is: how do i delete one item from one list when my list (List1) is an array of about 41 list boxes all named List1 (x) see....

also if I wanted that name which was double click to delete itself through the entire month, then ....well...the rest is my own trouble...but so far i can't seem to be able to delete.

grrr.
...

thanks in advance,
-munchkin

Editing List Items And ListSubItems In List View Control
Hi,

It is possible to edit ( add an entry ) the first column of a ListView control. By setting to automatic mode.

How do I edit the subsequent columns ( The listSubItems ).

BB

Finding List Item As U Typed In Combo Box(Dropdown List Style).
Basically the title say it all.

When I type a letter in combo box it finds item by matching the letter that I typed, but when I type in a second letter it searchs item that starts with the second letter.

I wonder is there a way to macthing list item as u typed in combo box(Dropdown List style).

Thanks in advance.
Joon

HighLight List Box Selected List Item With User Defined Color
Hi Friends,

I need a help from u all. My problem is to change the Backcolor of the selected listitem of a listbox.

Let me explain detail. Normally in a listbox if we selected the list, the list item will be highlited with blue backgroud (ie. the selected item color settings of the system). Now I need to hightlight the selected list in the list box with my own color say red, green or something else.

Would anyone help me.

V.P. Vijayavel

How To Change Back Color Of List Item In List View
Dear members,

i am having small problem with listview control , I want to assing alternate colors to list items, but i con't,

hope someone will help

regards
D.L.Narayana

How To List The Items Of Combo List When It Get Focus Without Click On It
Hi:
Here I have problem, I have a Combo list. If the user don't want to use mouse, and She want the Combo list list all of of it's item just like mouse click on it when she use TAB to focus on it. How can I implement this function. If anybody know about it. It will be very helpful
Millions of Thanks.


wky086

ListBox - Move List Item To Place In List
I have a list box with several items. I am trying to make a button that when the user selects an item in the list box, they can click on the button which will move the item up one in the list box:

So if my list looked like this:

ONE
TWO
THREE
FOUR
FIVE

and the user selected FOUR and clicked the button the list would look like this:

ONE
TWO
FOUR
THREE
FIVE


Does anyone know how to do this?

Thanks,
M

Change Background /Forgroound Of Each List Item In A List Box
How would i be able to change the back color of a listitem in a list control ? For example i want item number 1 to have a red background item number 2 to have a blue background etc.
Thanks for the help

Jerry

List Box, How Can I Paint Specific Items On A List
Hi,

I've got a list box, and I want to paint specific items on it.
I've tryed to use the ".forecolor" property, but it paints all the list.
also I've tryed to approach the specific item ".list(index).forecolor"
with no success

Thanks in advance, ofir

List Box, How Can I Paint Specific Items On A List ?
I've got a list box, and I want to paint specific items on it.
I've tryed to use the ".forecolor" property, but it paints all the list.
also I've tryed to approach the specific item ".list(index).forecolor"
with no success

Thanks in advance, ofir

List Box - Selecting Items To Be Displayed Into Another List Box
Hi,
I'm pretty new to this and for my assignment I've been set the task of using arrays (and saving the array in a Random Access file) but to to get to the point. This program currently adds and saves the array and then displays the user data into a listbox. However I want the list box items that have been saved to be displayed individually in another listbox (hope i'm making this clear.)
So for instance

In listbox LstUsers
I have records stored data which contains the name , address, postcode , package option chosen etc.
This information is pretty long so what I want the program to do is when the user selects one of these records in LstUsers it will then display that data in another List box called for example LstDetails.

I know i'd have to use an If statement but im unsure of the value i'm supposed to use. If anyone could give me a hand with this i'd be grateful thanks in advance.

Add A List Item To A Loaded Form List
help please. this is probably very simple.

i have a form loaded and showing. i need to add items to a list box, and my code is in a public sub in a different module.

my code follows. i wind up getting an "object doesn't support this type of property..."

i feel like i am close, i just don't seem to be referencing the form list correctly.

thanks much!

Public Sub BuildOverviewList()

Dim dbSOURCE As Database
Dim dbTARGET As Database
Dim rsSOURCE As Recordset
Dim rsTARGET As Recordset
Dim strDatabase As String
Dim strTable As String

strDatabaseName = "ProductCategories.mdb"
strTableName = "tblCurrentPresentation"
Set dbTARGET = OpenDatabase(dbPath & strDatabaseName)
Set rsTARGET = dbTARGET.OpenRecordset(strTableName, dbOpenDynaset)

'aryProductGroup provides the selected categories
For i = 1 To UBound(aryProductGroup)
'aryCategory1
For j = 1 To UBound(aryCategory1)
If aryCategory1(j) = -1 Then
strDatabaseName = "Category1_information.mdb"
strTableName = "CategorySlides"
Set dbSOURCE = OpenDatabase(dbPath & strDatabaseName)
Set rsSOURCE = dbSOURCE.OpenRecordset(strTableName, dbOpenSnapshot)
'write the record to the target table and add to list1
'USE THE ARRAY POSITION (j) TO GET THE SLIDE NAME FROM THE CORRECT TABLE
'ADD THAT SLIDE NAME TO THE LIST.
With rsSOURCE
rsSOURCE.Move (j)
With rsTARGET
.AddNew
![StepID] = 4
![CategoryID] = aryProductGroup(i)
![ProductID] = j
![Name] = rsSOURCE.Fields("SlideName").Value
.Update
End With
'Forms.frmPresOview6.List1.AddItem rsSOURCE.Fields("SlideName").Value
Forms.frmPresOview6.List1.AddItem rsSOURCE.Fields("SlideName").Value
End With
'also add record to ProductCategories/tblCurrentPresentation
End If
Next j

Next i

Create A Property Window Dropdown List AKA Listbox List/ItemData
I'm trying to create an enhanced listbox control (in VB6) and one of my main criteria is to make it funtion very similarly to the standard listbox control.
Creating dropdown lists of constants (i.e. the Style property) is easy enough. but I haven't been able to re-create the ability to add (array) items in the property window such as is possible with the standard Listbox List and ItemData properties.
Anyone know how (or if) this can be done in VB6?

Regards

Ant

Dragging List Items Around A List Box: Example
Since I can't post this in the code library, I thought I'd share it here. This code is pretty simple. It allows items to be reordered in a list box by dragging them around.

Put this in General Declarations

Code:
Dim item1 As String, item2 As String, listindex1 As Integer, listindex2 As Integer

Put this in for your list events.

Code:
Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'When the mouse is clicked, we want to save the text at the spot
'and the index of the spot to variables
item1 = List1.List(List1.listindex)
listindex1 = List1.listindex
End Sub
Private Sub List1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
'When the mouse is released, we want to save the text and the spot
'again. Then we print the text to opposite spots in the list.
item2 = List1.List(List1.listindex)
listindex2 = List1.listindex
List1.List(listindex1) = item2
List1.List(listindex2) = item1
End Sub

Importing List Items To Another List
i need a code which will import all the items of list1 to list2!

so that the lists will look identical!

Selects Items From List Box To List Box?
Hi everyone!

Has anyone seen a good example of how to set up a list box and then have an arrow button pointing to another list box which allows the user to select the items they want...... geesh this is hard to explain, and I dont know what to call it....

Basically the first box contains all of the possible selection avliable to the user and the highlight each one they want and hit the 'arrow' pulling those selected items into the 'selected' box. Make sense?? Most that I've seen professionally done include arrows to 'de-select' and another set to 'select all' and 'deselect- all'

Any pointers or examples on how to do this would be greatly appreciated. I currently have a well functioning program using just a single selection at a time and would like to upgrade it to have this type of functionality.

Thanks!
Willie

AddItem To Combo List And Have The Combo List Be Able To Retain The Item Upon Recall
I have a project that I need to do for school. You are to have a command button, a combo/dropdown list and a text box, you are to enter a name and birthday in the text box and when you click on the command button it is supposed to enter it in the combo box. My problem is that I got it to enter into the combo box with additem, but it will not retain the item that I just added. When I close the program the item I added does not stay there. How do I get the combobox to retain everything that I add through the textbox on command click. PLEASE HELP

Saving Items (selected Items) In List Box To A Text File
I need help in coding the following:

1. Saving (or exporting) the items displayed in List Box to a text file.

2. I have a long list of data to be displayed. When I use this List box all of my data does not fit into the width. I was wondering if there is similar other way where I can do horizontal as well as vertical scrolling. I tried text box and its of no help i guess.

ComboBox List/add Item, If Item Exists, Dont Add It Again!
Dudes and Dudeesses I need help!

I have a problem with a combobox within a form. I'm scanning down the spreadsheet for values and asking a combobox to .additem, however, the same value may appear twice whilst scanning down. Is there an if statement that will look and check the combobox to see if it is already added, if so dont add it again, if not, add it?

as below,

Code:
combobox.AddItem "Hotmail"
combobox.AddItem "Yahoo"
combobox.AddItem "Hotmail"
Hotmail will be added twice, how can I stop that?

If worst comes to the worst, I can sort it out with a long winded method, but I'm hoping theres a quicker way.

Thanks for all your help

Is There A Way To List Items In A List Box Using Tab?
I have a listbox with two variables (USER2(J) and ATTL) that lists a user's initials and then the total number of orders completed. Side by side together a user's name may be two initials or three initials - this throws off the PRINT output and even some initials like jfs may be smaller then emp! So I would like to really do a


Code:
List1.AddItem USER2(J); tab(10); ATTL

but it doesn't work...the List add item only recognizes & instead of ; and + and those items don't work either?

Any suggestions?

Thanks for the help.

Stephen

Single Item List Box (item Not Really Selecting)
Application=Access2002

The following code has worked for me in the past but won't now for some reason.
I have a private function and/or subs that performs a few simple operations such as setting listbox rowsources and simple math functions on a form. The queries set as rowsource use criteria from other single item listboxes.
Now, for some reason, the queries won't return values until the previously .selected(0) = true (single item) list boxes have been clicked on.
Problem has only been in creating a new form. Perhaps the problem did not occur in older created forms due to compatibility?


Private Sub fraEWTo_AfterUpdate()

[Edited]
    lstRotorHoursPriorTo.RowSource = "qryRotorSwapHoursTotTo" 'gets hoursprior from tblRotors
    lstRotorHoursPriorTo.Selected(0) = True ' This is one place where the problem seems to exist, the control does not function until it has been clicked on via mouse.

    LstClockInTo.RowSource = "qryRotorSwapRAHoursIPTo"
    LstClockInTo.Selected(0) = True

    txtRACHIPTo.Locked = False
    txtRACHIPTo.Value = txtClockHoursTo.Value - lstClockInTo.Value 'nor will this until the lstClockInTo box has been manually selected


A Mechanic in a Programmers shoes
Thanks




Edited by - greenfch on 12/7/2005 11:22:52 AM

List Box Item Scrolling (Next Item)
Hello,

I was wondering what the code would be for a command button to make the next item in the list box be selected?

Kind of like a NEXT button.
EXAMPLE:
List box Line 1
List box Line 2
List box Line 3
List box Line 4

If List box Line 2 is selected then clicking the next button would DESELECT List box Line 2 and SELECT List box Line 3.

If I didn't explain enough just let me know.

Stilekid007

Add All Items In List Box
I need to basically be able to add every item in the list box together but it is not working?

For I = 0 To lstTotalPrice.ListCount
TotalPrice = TotalPrice + lstTotalPrice.Text
Next I

lblNetCost.Caption = TotalPrice

It might be something to do with .Text as Im not sure which property I need to use?

Thans

List Items From A DB
hello all,

i want to be able to list items from a specified field in a DB and exclude duplicate entries.

is there an sql command to return this, or do i have to run a loop and store copious vaiables?

cheers,
A.


"Smoke me a kipper I'll be back for breakfast!"

Over 32k List Items
Alright, I am wondering what the best way to handle over 32k items is...I know a listbox can't handle over 32k items..I see some people say use a listview, and some say save the data to a variable..I tried a listview one time, but I didn't even know how to use it such as add items, etc..

Thanks

Using The List Items
Hi people, i want to keep the items inserted into a list in a form even if i hide and show the form constantly. thanks

List Certain Items...
Hiya,

I am trying to search through an ini file for any keys beginning with a certain number.

EG.

If the user typed:

10122003

in the textbox and clicked a command button it would return all the values of the keys starting with that number, for example:

101220031030
101220030145

and then list the values of them in a lstbox. I want them listed in order of the last four digits of the key number.

I am just returning to VB (had a few months break) and need to re-learn a few bits which is why I can't figure it out.

Can anyone help me out?

Thanks in advance

Kind Regards - Trvo

I suport public educasion.

Add Items List
is there a way to add items to a listbox or listview control during run time instead of design time?

List Items
We are trying to search the nominee year from the database. If the value is equal to that of the strvalue then it should display the nominee name in the listbox.

Attached is the code that i've been struggling with.

Currently what the code is doing is searching the database, but displaying the first name from the list as well as the first name from the nominee year/strvalue.

THE CODE CURRENTLY BEING USED:

Private Sub cmsave_Click()
Unload Me
End Sub
Private Sub Form_Load()
adovote.ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=F:Event Driven ApplicationsSAInts SRC system.mdb"
End Sub



Private Sub opt7_Click()
Dim strTable, strField, strValue As String
Dim K As Integer

With Me.adovote

strTable = "tblVoting"
.CommandType = adCmdTable
.RecordSource = strTable
.Refresh

strField = "Nominee_Year"
strValue = 7

.Recordset.Filter = strField & " Like '" & strValue & "'"

For K = 1 To 10
K = adovote.Recordset.RecordCount
If adovote.Recordset.DataMember = strValue Then
lstnominees.AddItem (adovote.Recordset![Nominee_Name])
'If .Recordset.Filter = strField & "Like '" & strValue Then

'Else: adovote.Recordset.Cancel 'MsgBox: No Nominees Found For This Year
.Refresh
'Next K
'End If
K = K + 1
Next K
End With
End Sub

Last List Box Item
I have a list box that is filled dynamically and I don't know in advance how many items it will contain. How can I get the last item value? Here is what I tried:

Code:
lstBibPlace.Index(lstBibPlace.ListCount - 1)
but that generated a 'wrong number of arguments' error message.

Thanks!

List Item I
I have a loop here for saving a list's contents. i want the i item of the list. how can i take that? and as soon as i save i want to store the i item read from the file put into the list. how can i do that too? thanks anyway for any answers....

Add Item To List Box
Hi,
Below is the code im using to sort a file into a list box.
Only thing is though im putting it into a rich text box first.
When i do this the file is to big and so when it goes to sort it i get an overflow error.

How can i chnage this code so it dosent go through the right text box and gets sorted into the list box straight away.


Code:
otext = Display.Text
mtext = Replace (otext , Chr$(0) , " ")

Display.Text = mtext

Dim Count As Integer
Count = 0

Dim sentence As String
sentence = "the fat cat eats fork.txd from the can"

Dim words() As String
words = Split(sentence) ' Split up the sentence into words

Dim i As Integer

For i = 0 To UBound(words) ' Loop through each word
Dim word As String ' Set the word to a variable
word = words(i)

If Right$(word, 4) = ".txd" Then ' If the word ends in .txd
Count = Count + 1
List1.AddItem Count & ": " & word
End If
Next i

Thanks for any help.
-Dave

Add An Item To List 6
I would like to add an item to list 6 after pressing a button.

the item simply and always says End of Search. Can anyone tell me how to do this?

Also I have a timer8 and it counts in seconds. Is there a way that when the button is pressed, the timer is enabled and starts to count, and as each second goes on, a labeltime.caption number is increased by one. And when the list 6 gets the end of search item added to it, the timer is disabled? thanks!

Add An Item In A List Box
I have a list box and i am trying to add elements as follows

ns = 4
Dim temp As String
For x = 1 To ns - 1
temp = "Stage " + x + " Oulet"

List1.AddItem temp, List1.ListCount
Next

Basically i would like the items in the list box to appear as follows:

Stage 1 Outlet
Stage 2 Outlet
Stage 3 Outlet
etc

A mismatch error comes up when i try to this!
I tried to change the + x + part of the expression to
+String(x) +
But this did no work either!

Please help !!!

List Box Item
I have to list box. If i add an item from list1 to list2 and the item already exists a beep sound

But how can i change the color of that item in list2 and make it blink?

Going To Next Item In List??
ok, here's a tricky one. Say I have 3 filenames in a listbox. when the user double-clicks on the file, my program calls on the Shellexecute API call to open the file with it's default program. ok say for example these are *.wav files. When the first file in the list is finished playing I want the program to automatically go to the next file in the list and use shellexecute to open it. So my question is: How can I get my program to recognize when the playing file has finished playing? Any suggestions, tips, flames, etc. appreciated. Thanks

-Jeremy

Last Item In A List Box
How do I go about getting the last item in a list box?


-Thanks

Last Item In List Box Seems To Be 0
Hi there
I have a listbox with checkboxes

I am looping through the selected items but it seems that it always makes the last item 0

CODE    Dim n As Long
    With courselist
    For n = 0 To .lst_files.ListCount - 1
        If .lst_files.Selected(n) = True And .lst_files.List(n) <> "" Then
            MsgBox (.lst_files.List(n))
        End If
    Next
    End With

Get Item From The List Box
Hi! Can you please help me on how to get the item from the list box... like if i click one of the item from the list box, i want it to be shown in a text box but i dont know how to do it. i have tried to set it by using adodc but the problem is i only get the first item and no more. Thanks a lot!!!

Next Item In List
I want to make it so that when i click a button(command1) it makes the listbox (list1) select the next selection in it. So everytime i click the button the selection moves down one. Can someone please help?

Colors Of Items In A List Box
if I change the color using lst.forecolor = vbred then it changes all items in the list box to red.

Is there a way to make a specific item in a list box one color and make all the others a different color?

Loop To Add List Box Items
Hello there,

I have attmpted a For To Next Loop and a Do While Not Loop to add all the items from my list box.
Here's a look at both loops.

1)

Code:
Private Sub List0_DblClick(Cancel As Integer)
Dim s As Integer
For s = 0 To List0.ListCount
List1.AddItem List0.ItemData(s)
Next s
End Sub
This loop adds item as desired but prompts an error message at the end.
Run-time error 94 Invalid use of Null.

2)


Code:
Private Sub List0_DblClick(Cancel As Integer)
Dim i As Integer
i = List0.ListCount
Do While Not i = 0
i = i - 1
List1.AddItem List0.ItemData(i)
Loop
End Sub
This loop adds item from bottom to top since it starts from ListCount's value and - 1.

I'll like to have my items added the correct way without the error, can anyone comment on my loops and give suggestions?
will be more than glad to learn new ways of looping.

Thank You


Astrov

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