View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Counting textboxes

You must be reading different code to me as the code I see increments
countTextboxes which is the name of the function.

--
HTH

Bob Phillips

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

"mooncrawler" wrote in message
. ..

The difference between a function and a subroutine is that a function

always
returns a value.
Your function does not. I would do it a little different:

Public Function countTextboxes( oUF As UserForm ) as Long
Dim iCtrl As Long
Dim i as integer
For iCtrl = 0 To oUF.Controls.Count -1
If TypeName(oUF.Controls(iCtrl)) = "TextBox" Then
i = i + 1
End If
Next iCtrl
countTextboxes = i
End Function


From your form-macro, you call i.e.

Dim x As Long
x = countTextBoxes( Me )






"franzklammer" schreef in bericht
...
Hello! I got this piece of code from someone who helped me with a

function
that counts the number of textboxes in a user form. However I do not not
what
what 'oUF' means and how to use the function. I have never used

functions
before so I do not know how to call it. I tried useing 'Call
countTextboxes'
in another Sub but I suppose that you need something else...

Public Function countTextboxes(oUF As UserForm) As Long
Dim iCtrl As Long
For iCtrl = 0 To oUF.Controls.Count - 1
If TypeName(oUF.Controls(iCtrl)) = "TextBox" Then
countTextboxes = countTextboxes + 1
End If
Next iCtrl
End Function