Solved

Setting the value of a combo box

Posted on 2003-11-20
7
292 Views
Last Modified: 2010-05-01
I have a combo box (ListType) with the values:

ListType.additem ("1")
                              2
                              3
                              4
                              5
                              6

On_Load I want to set the value of the ComboBox

     ListType=3

then take the listindex of the combo box and set it equal to another combobox

     ListTypeF.ListIndex=ListType.ListIndex

How can I do this?

   - Marc
0
Comment
Question by:MarcGraff
  • 4
  • 3
7 Comments
 
LVL 28

Expert Comment

by:vinnyd79
ID: 9788256
Do you mean something like this?

Private Sub Form_Load()
With ListType
    .AddItem "1"
    .AddItem "2"
    .AddItem "3"
    .AddItem "4"
    .AddItem "5"
    .AddItem "6"
End With

With ListTypeF
    .AddItem "1"
    .AddItem "2"
    .AddItem "3"
    .AddItem "4"
    .AddItem "5"
    .AddItem "6"
End With

ListType.ListIndex = 2 ' to set to #3

ListTypeF.ListIndex = ListType.ListIndex


End Sub
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 9788263
or maybe:

Private Sub Form_Load()
With ListType
    .AddItem "1"
    .AddItem "2"
    .AddItem "3"
    .AddItem "4"
    .AddItem "5"
    .AddItem "6"
End With

ListType.Text = "3"

ListTypeF.Text = ListType.Text

End Sub
0
 
LVL 1

Author Comment

by:MarcGraff
ID: 9788313
My appologies, ListTypeF contains

     ListTypeF.additem "Stuff"
                                   "dshgaljsh"

are all all words... This is why I am trying to use there listindex.

   - Marc
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 1

Author Comment

by:MarcGraff
ID: 9788334
also ListType may have diffrent numbers in diffrent circumstances therefore I can not say .listindex=3 because sometimes that will give me a "2" and other times a "6"

Sorry,
   - Marc
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 9788425
How about:


Private Sub Form_Load()
Dim i As Integer

With ListType
    .AddItem "1"
    .AddItem "2"
    .AddItem "3"
    .AddItem "4"
    .AddItem "5"
    .AddItem "6"
End With

With ListTypeF
    .AddItem "Item1"
    .AddItem "Item2"
    .AddItem "Item3"
    .AddItem "Item4"
    .AddItem "Item5"
    .AddItem "Item6"
End With

ListType.Text = "3"

For i = 0 To ListType.ListCount - 1
    If ListType.List(i) = ListType.Text Then
        Exit For
    End If
Next i

ListTypeF.ListIndex = i


End Sub
0
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 250 total points
ID: 9788449
You could also add this to the ListType's click event to have ListTypeF to change when listType is changed:

Private Sub ListType_Click()
Dim i As Integer
For i = 0 To ListType.ListCount - 1
    If ListType.List(i) = ListType.Text Then
        Exit For
    End If
Next i

ListTypeF.ListIndex = i
End Sub
0
 
LVL 1

Author Comment

by:MarcGraff
ID: 9788638
Sweet! Thanks so much!

   - Marc
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Vb.net Listview 9 76
Problem to the message 13 63
using Access 8 52
MS Date Picker 64 bit 32 bit issue 12 43
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now