Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 167
Default Passing a Forms Control to Function

I want to write a function that checks a listbox for an entry and reports
true or false. I want the input to be the listbox to check and the potential
entry. How do I pass the listbox to the function?

Thanks,
Pflugs
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Passing a Forms Control to Function

as an example


Function myFunc(lb As MSForms.ListBox)
MsgBox lb.Value
End Function


and in the form

myFunc Me.ListBox1


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Pflugs" wrote in message
...
I want to write a function that checks a listbox for an entry and reports
true or false. I want the input to be the listbox to check and the

potential
entry. How do I pass the listbox to the function?

Thanks,
Pflugs



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Passing a Forms Control to Function

Function myFunction(myLB as msforms.listbox) as boolean

End Function

I'm not sure what you mean by potential entry, though.



Pflugs wrote:

I want to write a function that checks a listbox for an entry and reports
true or false. I want the input to be the listbox to check and the potential
entry. How do I pass the listbox to the function?

Thanks,
Pflugs


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 167
Default Passing a Forms Control to Function

Thank you, that worked well.

I have one more question, if you please. I am trying to return the value of
a list item at index "i"; that is, looping through the list and reporting the
string of the selected items. After reporting them, I'd like to remove them
from the list, but each time I remove one, it changes the indexes. Is there
a better way to get around this?

Thanks,
Pflugs


"Bob Phillips" wrote:

as an example


Function myFunc(lb As MSForms.ListBox)
MsgBox lb.Value
End Function


and in the form

myFunc Me.ListBox1


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Pflugs" wrote in message
...
I want to write a function that checks a listbox for an entry and reports
true or false. I want the input to be the listbox to check and the

potential
entry. How do I pass the listbox to the function?

Thanks,
Pflugs




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Passing a Forms Control to Function

loop in reverse

With listbox1
for i = .listcount - 1 to 0 step -1
if .selected(i) then
.removeitem i
end if
next
End with

--
Regards,
Tom Ogilvy


"Pflugs" wrote:

Thank you, that worked well.

I have one more question, if you please. I am trying to return the value of
a list item at index "i"; that is, looping through the list and reporting the
string of the selected items. After reporting them, I'd like to remove them
from the list, but each time I remove one, it changes the indexes. Is there
a better way to get around this?

Thanks,
Pflugs


"Bob Phillips" wrote:

as an example


Function myFunc(lb As MSForms.ListBox)
MsgBox lb.Value
End Function


and in the form

myFunc Me.ListBox1


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Pflugs" wrote in message
...
I want to write a function that checks a listbox for an entry and reports
true or false. I want the input to be the listbox to check and the

potential
entry. How do I pass the listbox to the function?

Thanks,
Pflugs






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 167
Default Passing a Forms Control to Function

Good call. Thanks.
Pflugs

"Tom Ogilvy" wrote:

loop in reverse

With listbox1
for i = .listcount - 1 to 0 step -1
if .selected(i) then
.removeitem i
end if
next
End with

--
Regards,
Tom Ogilvy


"Pflugs" wrote:

Thank you, that worked well.

I have one more question, if you please. I am trying to return the value of
a list item at index "i"; that is, looping through the list and reporting the
string of the selected items. After reporting them, I'd like to remove them
from the list, but each time I remove one, it changes the indexes. Is there
a better way to get around this?

Thanks,
Pflugs


"Bob Phillips" wrote:

as an example


Function myFunc(lb As MSForms.ListBox)
MsgBox lb.Value
End Function


and in the form

myFunc Me.ListBox1


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Pflugs" wrote in message
...
I want to write a function that checks a listbox for an entry and reports
true or false. I want the input to be the listbox to check and the
potential
entry. How do I pass the listbox to the function?

Thanks,
Pflugs



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between a Forms Control verus Active-X Control funGT350 Excel Discussion (Misc queries) 6 May 6th 08 11:20 PM
Is tabbing function available when using control forms? steve1962 Excel Worksheet Functions 0 May 1st 07 09:03 PM
passing variables between 2 forms burl_rfc Excel Programming 3 April 14th 06 05:49 AM
Passing variables between forms Sami82[_8_] Excel Programming 7 October 8th 05 12:12 AM
User Forms - passing data between them mickiedevries Excel Programming 3 June 21st 04 08:59 PM


All times are GMT +1. The time now is 07:12 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"