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




Quick Question: Listbox And Substituting Text For List Item


Ok, here's the problem: I've got my listbox right? I have a whole bunch of list items in the list box that have a very very long caption. Now what I want to happen is when a user clicks one of those captions, it is to have some DIFFERENT text to be stored into a variable. Like I click the list item, a separate piece of text is then stored into a string variable. Then later on, in a different form, I want to be able to use that variable to display the text instead of the text in the list box. I have some code set up but I am not exactly sure how to manipulate it.


VB Code:
Private Sub List1_Click(Index As Integer)Dim NPC1 As StringNPC1 = List1(0).TextDim NPC2 As StringNPC2 = List1(1).TextDim NPC3 As StringNPC3 = List1(2).TextDim NPC4 As StringNPC4 = List1(3).TextDim NPC5 As StringNPC5 = List1(4).TextDim NPC6 As StringNPC6 = List1(5).TextDim NPC7 As StringNPC7 = List1(6).TextDim NPC8 As StringNPC8 = List1(7).Text End Sub


Do I need to like have a line after that, that states:


VB Code:
Private Sub List1(6).Text_Click()NPC1 = ["textblahblah"]


Thanks!




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Quick Listbox Questions (Move To Next Item)
Simple: Listbox and cmd button.

When I click the command button, the selected listbox item should move to the next item in the listbox. Click the cmd button again and the selected entry in the listbox should move to the next one.

Any help?

Quick Listview Question - Getting A Selected Item To Appear At The Top Of List
Hopefully a simple question - I have a list view and items are added at run time by the click of a button, the newly created item is selected but since the list view is sorted it might be selected but off the bottom of the list view window. Obviously the user can scroll down to look for it but this isn't very slick. Can I automatically force the list view to scroll down to the right place or bring one item to the top of the list view??

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

Substituting A ListView For A Combo's Dropdown List
Hi

The code below attaches the Listview1 to Combo1 of Form1. But it can't attach ListView2 to Combo2 of Form2. What i mean is, i want to attach any Listview to any Combo of any Form. So how can modify this code in such a way that will satisfy my requirement.

Please help me with this issue.



To a form, add a combo (Combo1), a listview control (ListView1), and three command buttons (Command1, Command2, Command3). Set the Style property of the Combo to Style 2, and add the following code to the form:


VB Code:
' Form Code' ======= Option Explicit Private bKeepOpen As Boolean Private Sub Form_Load()    Dim c As Long   Dim chd As ColumnHeader   Dim itmx As ListItem     'Add some dummy data to the listview and hide   With ListView1            Set chd = .ColumnHeaders.Add(, , "Name", 1000)      Set chd = .ColumnHeaders.Add(, , "Col 2", 1000)      Set chd = .ColumnHeaders.Add(, , "Col 3", 1000)      Set chd = .ColumnHeaders.Add(, , "Col 4", 600)            For c = 1 To 15         Set itmx = .ListItems.Add(, , Screen.Fonts(c))         itmx.SubItems(1) = "screen"         itmx.SubItems(2) = "font"         itmx.SubItems(3) = c      Next            .View = lvwReport      .FullRowSelect = True  'vb6 only      .BorderStyle = ccNone      .Visible = False            End With   'set inital state of command buttons   Command1.Caption = "hook combo"   Command2.Caption = "unhook combo"   Command3.Caption = "unhook && end"   Command1.Enabled = True   Command2.Enabled = False   End Sub  Private Sub Command1_Click()    If defWinProc = 0 Then      Hook Combo1.hwnd      Command1.Enabled = False      Command2.Enabled = True   End If   End Sub  Private Sub Command2_Click()   'unhook the combo   If defWinProc <> 0 Then      Unhook Combo1.hwnd      defWinProc = 0      Command1.Enabled = True      Command2.Enabled = False         End If   End Sub  Private Sub Command3_Click()    Unload Me End Sub  Private Sub Form_Unload(Cancel As Integer)    If defWinProc <> 0 Then Unhook Combo1.hwnd    End Sub  Private Sub ListView1_KeyDown(KeyCode As Integer, Shift As Integer)   'set flag to allow arrow and enter  'keys to simulate behaviour of normal  'combo   bKeepOpen = True End Sub  Private Sub ListView1_KeyPress(KeyAscii As Integer)   'set flag to allow arrow and enter  'keys to simulate behaviour of normal  'combo   If KeyAscii = vbKeyReturn Then           'simulate selecting item with enter      bKeepOpen = False      Call ListView1_Click   Else        'alpha or arrow keys being used,     'so keep open      bKeepOpen = True         End If      End Sub  Private Sub ListView1_Click()    Dim itmx As ListItem    If ListView1.ListItems.Count > 0 Then       Set itmx = ListView1.SelectedItem      'For a style 0 combo, you can not assign     'to the Text property from within the click     'event, so the selected item must be 'added'     'as the only combo item, and selected using     'its listindex property.     '     'For a style 2 combo, the text property     'can't be set unless there is an exact     'match to a list item, so again we fake it     'by adding the selection to the combo and     'selecting it.     '     'Finally, since the tabs can't be used     'in the combo's edit window, as it doesn't     'support tabstops either, on selection we'll     'display the main listview item      With Combo1         .Clear         .AddItem itmx.Text         .ListIndex = 0      End With    End If    If bKeepOpen = False Then      ListView1.Visible = False      Combo1.SetFocus   End If   End Sub



VB Code:
' BAS Module Code' ============ Option Explicit Public defWinProc As Long Public Const GWL_WNDPROC As Long = -4Private Const CBN_DROPDOWN As Long = 7Private Const WM_LBUTTONDOWN As Long = &H201Private Const WM_KEYDOWN As Long = &H100Private Const VK_F4 As Long = &H73 Private Declare Function CallWindowProc Lib "user32" _   Alias "CallWindowProcA" _  (ByVal lpPrevWndFunc As Long, _   ByVal hwnd As Long, ByVal Msg As Long, _   ByVal wParam As Long, ByVal lParam As Long) As Long Private Declare Function SendMessage Lib "user32" _   Alias "SendMessageA" _  (ByVal hwnd As Long, _   ByVal wMsg As Long, _   ByVal wParam As Long, _   lParam As Any) As Long Public Declare Function SetWindowLong Lib "user32" _   Alias "SetWindowLongA" _  (ByVal hwnd As Long, ByVal nIndex As Long, _   ByVal dwNewLong As Long) As Long  Public Sub Unhook(hwnd As Long)       If defWinProc <> 0 Then         Call SetWindowLong(hwnd, _                         GWL_WNDPROC, _                         defWinProc)      defWinProc = 0   End If    End Sub  Public Sub Hook(hwnd As Long)    'Don't hook twice or you will   'be unable to unhook it.    If defWinProc = 0 Then          defWinProc = SetWindowLong(hwnd, _                                 GWL_WNDPROC, _                                 AddressOf WindowProc)          End If    End Sub  Public Function WindowProc(ByVal hwnd As Long, _                           ByVal uMsg As Long, _                           ByVal wParam As Long, _                           ByVal lParam As Long) As Long    'only if the window is the combo box...   If hwnd = Form1.Combo1.hwnd Then         Select Case uMsg               Case CBN_DROPDOWN  'the list box of a combo                            'box is about to be made visible.                      'return 1 to indicate we ate the message            WindowProc = 1            Case WM_KEYDOWN   'prevent the F4 key from showing                           'the combo's list                        If wParam = VK_F4 Then                          'set up the parameters as though a              'mouse click occurred on the combo,              'and call this routine again               Call WindowProc(hwnd, WM_LBUTTONDOWN, 1, 1000)                           Else                          'there's nothing to do keyboard-wise              'with the combo, so return 1 to              'indicate we ate the message               WindowProc = 1                        End If                     Case WM_LBUTTONDOWN  'process mouse clicks                    'if the listview is hidden, position and show it            If Form1.ListView1.Visible = False Then                           With Form1                  .ListView1.Left = .Combo1.Left                  .ListView1.Width = .Combo1.Width                  .ListView1.Top = .Combo1.Top + .Combo1.Height + 1                  .ListView1.Visible = True                  .ListView1.SetFocus               End With                           Else                               'the listview must be visible, so hide it               Form1.ListView1.Visible = False            End If              'return 1 to indicate we processed the message            WindowProc = 1                  Case Else                    'call the default window handler            WindowProc = CallWindowProc(defWinProc, _                                        hwnd, _                                        uMsg, _                                        wParam, _                                        lParam)         End Select      End If  'If hwnd = Form1.Combo1.hwnd   End Function

For Each List Item In Listbox
I have a list box which displays the usernames on my computer. how do i use the for each statment to pass the usernames so the code can be repeated for each user.

Thanks in advance
Chris1990

Listbox - Take First Item In List?
How do I extract the first line in a listbox? I know that to take data out you use lstBox.Text, but how do I automatically select line 1 before doing this?

Move List Item Up And Down In Listbox
How do I move a line up and down in a listbox?

How To Get All List Item From A Listbox Of An External Program?
I want my program to get all the list item from a listbox of an external/another program and transfer it to my program's listbox. The external/another program have a two listbox and also my own program. How can I programmed it? And it is possible to automatically add item to my listbox when the listbox of the external program add another item to the listbox? Thanks in advanced.

Substituting Letters For Numbers I Na Text Box
Hey guys, I'm wondering if a text box has something like NaCl, then when you press a button you get the molar mass of the combined NaCl together in another textbox?

another if you had H2O, where you have 2 H and 1 O could that be done, I mean if you had a access database of all molar mass in it with the atomic symbol, but how could you subsitute more than one value in a single text box?
Thanks guys

Show Full Name Of A List Item Which's Name Exceeds The Listbox's Width?
I have a list that displays full filenames with paths and all. These names usually get pretty long, and exceed the listbox's width. How can I display their full names without using another label or textbox which will display it when they are selected? Something more like the ControlTipText. Please help.
10x

Solved-howto Send First Item Of Listbox Totextbox, Then Delete First Item Of Listbox?
Lol another question, how do you do this

how to send first item of listbox to textbox, then delete first item of listbox?

Thanks

Change ListBox Item Text?+ Change Item Color Or Status?
hi
I'm new to VB. I want to change the text of a ListBox item.
I used AddItem to add items.
Then I tried to change a selected item using lst.Text = "somethingNew", but it doesn't work...
Pl. help

And need to know.. how to change the color of an item or status(disable) of an item???

Thanks

How To Get The Text Of Item In A Listbox?
I am using a test tool that uses VBA as its back end. When I record the action the tool itself only recongnizes the NAME of the item selected in the list...in most cases this is best.

However, I really need it to select by text, but this does not seem to work. So I want to write a little VBA that will extract the text of the displayed selection in the listbox after my test tool plays back the selection.

Example:
the text displayed is "English"
the name of this item is "en-US"

I want:
textDisplayed = text.listbox, which will mean textDisplayed = "English"

I was wondering what the syntax for this is? rather new to VB.

Thanks in advance

Listbox Item Text
Hello, i want to display the text in a listbox item.

list1.text will display for the selected text
however,
i want to obtain the text for a particular item in the list

ie: get list1 item 3's text

Get Text Of An Item In A List Box
Ok, I want the text from a listbox, but not the item which is selected, I want to specify the number of the item.

Thanks
Tom

Listbox - Changing The Text Of Item
Hi I have included an example in the zip file to show what i'm trying to do:

I have three checkoption boxes - Apple, Banana and Orange and
a listbox (list1)

When the checkbox is ticked the item appears in the list1 listbox - All this works fine but now I need to do one more thing

If the items Apple, banana and orange are in the listbox I need to be able to change the item name into its colour for example on double click turn:

The text 'apple' into the text 'Green' or the text 'banana' into 'Yellow' or 'orange' into the text 'same as fruit' - but only the item selected and not all of them in one go

Because I want to be able to keep some items as the fruit name and change others to the colour of the fruit

Is this even possible and if so any advise on how to do it?

Modify The Text In A Listbox Item
I have a list box in a Excel Form. at some point i want to modify the text of the selected item in the list box. When i use lstItems.Text="xyz", its not accepting.
I dont want to delete and add the item as there is no "sort" option for the listbox. If anybody knows please let me .
Thanks
Vijay S

Listbox Text Item Forecolor
I have a List box with a number of entries listed from a database.
I need a way of changing the font style to italic for an individual entry on a certain condition:

For example:

If the text of say listindex number 2 = "Products" then i need just that line to be italic

is it possible using ordinary listboxes?

thanx

clax

Removing An Item From A Listbox Specifing The Text
hi to all!!!

first of all... good forum! i'm a newbie , i have just registered

(... i'm italian... )

my question is:
can I remove an item from a list box specifing the text?

example: I write the caption of a listbox item and by clicking a button i want to remove it.

(.. I hope you have understood )

simply: i want to remove an item specifing the caption and not the index of the item


greetz
simons

Listbox: Change Text Of Selected Item
hi all,

just wondering if anyone knows a way of changing the text of the selcected item in a list box?

for example: if i have a listbox with the following list items:

one
two
three
four

and "two" is selected, and i need to change its text to "this one".

i would like to avoid regenerating the list by clearing it and adding all the items again if possible.


thanks for your time and consideration,

mojoinst

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

How Can I Set The Text To Bold In The Selected Item Of A Listbox.
how can I set the text to bold in the selected item of a listbox. I need it to be like that until another file listitem is double clicked.

Reading Individual Item Text From A List Box
Hi, this is a really simple one i guess but I certainly can't work it out. I would like to search through a listbox searching for a specific string item. I can't find the listbox function that outputs an item... as a little example.. how would I say, output the text from the listboxes second item to a messagebox??... I tried

msgbox lstCat.list(1)

though this seems way off the mark. Thanks for any help, kind regards,

Rich.

List View - Drag Item In A Text Box
Hi!

I´m using a List View and some text boxes. I want populate the text of text boxes drop&draging the items of my list view. It's that possible? Any trick? Thanks in advance,

Hélder Barros

Listbox Remove Item By Matching Text With A Textbox
Is it possible to remove a item from a listbox but no using index removing a item with the same text as the text in a textbox instead.

Eg

I had a listbox with this in

Hello1
Hello2
Hello3
Hello4

and i had a textbox with the text

Hello4

in it.

Is it possible to remove a item from the listbox by matching the text in the textbox with the same text in a the listbox and then removing that item.


vb Code:
list1.removeitem (text1.text)


I no that wont work, just i don't really know how to explain it.

Thanks

Find Text Value Of Current List Item? *Resolved*
I would like to cycle though a list and execute a command for each item in the list.
What is the attribute that would allow me to know the Text value of the current list item?

Code:
Private Sub cmdGenerate_Click()
    Dim i
    For i = 0 To lstNumbers.ListCount - 1
        GenerateNumberList
        txtMultiVehicleAdCopy.Text = txtMultiVehicleAdCopy.Text & "Yahoo! It worked" & vbCrLf
    Next i
End Sub

Private Sub GenerateNumberList()
 'I want to take the text value of the current list item and jump to that record BUT I cant seem to figure out how to find the current list item info/text

   Data1.Recordset.MoveLast
   Data1.Recordset.FindFirst "Number='" & lstNumbers.Text & "'" '<---Takes the List item Text and uses it to move the datacontrol to the record
'Need to know the value of the current list item "lstNumbers.Text" ??? doesn't give me the current list item text ie: "Item Number One" "Item Number Two" etc.

    If chkCheckbox1.Value = True Then
     txtNumberList.Text = txtNumberList.Text & "Yahoo!"
    End If
End Sub






Edited by - Matrix1000 on 12/15/2003 3:18:39 PM

(? Help) Change Listbox Selected Text Without .additem Or .remove Item
Hi, I browsed through posts and didnt see this question elsewhere so I hope I didnt miss it if it was answered already. If so im sorry.

I was wondering if there is anyway to change the selected text entry for a list box without adding or removing an item.

Example: If there were these options in a list box:

A
B
C

and "B" had been selected by the user is there anyway to change "B" to "D" without using the .additem or the .remove command? If you need me to restate or clarify what im asking please let me know and Ill repost as soon as I see it. Thanks for any help I get in advance.


- Sidenote: I would use a loop and simply add them into another list box and back into that one in a different in the correct order but theres some sticky and touchy coding done on the list box's _click statement that really wouldnt make such a loop possible....if this sidenote didnt make sense sorry its 5 am .

How Make Long Text Item In A List Shown Multiline ???
how make long text item in a list shown multiline ???

How To Search Listbox For Item If Item Not Found Add Item?
Hi, lol man I cant find nothing today when I search the forum.

This my latest problem, How do I search a listbox for an item lets say "Game Over" And if the item is found the program does nothing, but if the item is not found it will add "Game Over"

Thanks Again

Returning Text From A Listbox ... Cannot Use ListBox1.List
Hi there,

Does anyone know how to return the text from a listbox using VBScript with Access Forms.

Access VBScript does not like ListBox1.List and all I appear able to do is return the bound value of the listbox, but I need to return the values of 2 other fields listed in the listbox.

Please help!

Thanks,
Brian.

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

Need To Update Text Box By Double Clicking List In Listbox
Hi eveyone,

I wanted to know, if I have a form in access that displays a list of schools, how can I update a text box in another form by double clicking on the list. So for example if I have a textbox that displays the name of the school and a bottom next to it that says assign new school, on pressing the button it displays the list of schools and double clicking on the name of the list updates the textbox.

How can this be done?

Removing An Item From A ListBox By Clicking The Item
Hi, How do you remove an item from a ListBox by simply clicking the item u want to be removed?

This is the code i tried but it doesnt work:

Private Sub list1_Click()
Dim n As Long
Dim ncount As Long

ncount = List1.ListCount - 0
For n = 0 To ncount
List1.RemoveItem (n)
Next
End Sub

Any ideas?


-Flaw

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

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

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

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

Populate A Listbox Based On A Selected Item In Another Listbox
Ok...I am stumped.

I have a single form that has 3 list boxes. I have 4 public strings containing various values. Based on the selection from lstBox1, I need to populate the ListBox2 and ListBox3 list from values in the public strings. Clear as mud?? That is what I thought!

Example string variable

strLuxury = """Hand Wash"" ""Hand Wax"" ""Check Engine Fluids"" ""Detail Engine Compartment"" ""Detail Under Carriage"" ""Fragrance"" ""Shampoo Carpets"" ""Shampoo Upholstery"" ""Scotchgard"""

ListBox1 contains the following:

Standard
Deluxe
Executive
Luxury

ListBox2 is empty, but is contained in a frame indicating Exterior Options
ListBox3 is empty, but is contained in a frame indicating Interior Options

If Luxury is selected in ListBox1, then ListBox2 should contain
Hand Wash
Hand Wax
Check Engine Fluids
Detail Engine Compartment
Detain Under Carriage

And ListBox3 should contain
Fragrance
Shampoo Carpets
Shampoo Upholstery
Scotchgard

If Fragrance is present in ListBox3, a seperate dropdown box should appear allowing selection of the appropriate scent.

Yes, this is a homework assingment.

Thank you in advance for your help!
Mark

Transfering Item From One Listbox To Anotehr Listbox On Click
Hi all i got 2 listbox . I want to be able to click on my first listbox items and once i click on them it transfers to the second listbox. Could any one tell me how that can be done.Thanks

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.

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

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

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

How To Add A Listbox Item To A Listbox On Another Form Within The Project.
What is the best method to take an item selected in a listbox and add it to another listbox on a different form within the same app?

.: Please Help: Copy Selected Item(s) From A ListBox To The Other ListBox..
Hi everyone!

I'm having problem with copying file to another Listbox, please help..
So, in this case, I have two ListBoxes where the 1st ListBox holds several items..
I need to copy the selected item to the other listbox 'without' a repetition, I mean.. the same item won't copied anymore..
When the user tries to copy the item which have already been in the ListBox2, then a messagebox will pop up to warn the user of the existing item.... So, how should I do that??


Thanks a lot

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

Substituting A Parameter Name With It's Value
I am trying to substitute a parameter with it's value.

Ex.

Public Sub in_pram()

Dim pram As String
Dim AUXLOC As Double

pram = "AUXLOC"

??pram = 6 (I want to substitute pram with it's value AUXLOC)

'The value it should return should be AUXLOC = 6

End Sub


This is going to be inside of a loop and the value of "pram" will change. If you have any questions about my question. Please contact me at pruetta@yahoo.com

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