check that user selected a value in a list box

J

joncohen

I am trying to validate if a user selected a value in a listbox. Does anyone
know how to display a message if the listbox has no selected values?

Thanks in advance.

Jonathan
 
H

Helmut Weber

Hi,

listindex returns -1
if no item is selected.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
J

joncohen

Helmut,

Thank you for your reply, my issue is that the msgbox displays twice after
verifying that the listbox does not have a selected item. I must be missing
where to validate the listbox so that i can return the user back to this
listbox. Any assistance would be appreciated, thank you.
 
H

Helmut Weber

Hi Joanthan,

as Jay pointed out, make sure,
that there is always something selected.

I'd add an entry like "---" as item 0,
select always item 0 as the default item
and check afterwards,
if an item other than item 0 was selected.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top