Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 04-01-2022, 03:19 AM
grNadpa grNadpa is offline how do I handle user input not in combobox Windows 10 how do I handle user input not in combobox Office 2016
Advanced Beginner
how do I handle user input not in combobox
 
Join Date: Mar 2022
Posts: 46
grNadpa is on a distinguished road
Default

By restating my question (below), I blundered into my answer.

Assume a combox containing "Adam", Beverly" and "Charles". When the client selects one of those, I want to capture the Listindex. If, instead, the client types in something else, I want to capture what the client typed (e.g. "Alfred"). Is there a way in VBA to do that? Preferably without requiring another control.

Code:
Private Sub CommandButton1_Click()
    With ComboBox1
        .AddItem "Adam"
        .AddItem "Beverly"
        .AddItem "Charles"
    End With
End Sub
Private Sub ComboBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    With ComboBox1
        MsgBox "Listindex: " & .ListIndex
        MsgBox "Name: " & .Text
    End With
End Sub
That is, thought I had tried _Exit event before. Whatever I coded didn't work at the time so thought it was the strategy. Apparently it was just the coding.

Last edited by grNadpa; 04-01-2022 at 05:35 AM. Reason: Solved
Reply With Quote
 

Tags
vba combobox



Similar Threads
Thread Thread Starter Forum Replies Last Post
User input box with IF statement ChrisJ83 Word VBA 9 11-13-2015 06:20 PM
Taking input from InputBox from user SeattleITguy Excel Programming 1 01-28-2015 09:05 AM
how do I handle user input not in combobox vba: user input named argument andrew12345 Excel Programming 2 11-18-2014 08:18 AM
how do I handle user input not in combobox User input to a variable on the document dsm1995gst Word VBA 1 09-03-2013 03:43 PM
how do I handle user input not in combobox Replacing text with user input.?.?.? brad1977 Word 3 11-20-2012 10:20 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:19 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft