ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Function Argument (https://www.excelbanter.com/excel-programming/308659-re-function-argument.html)

Chip Pearson

Function Argument
 
Try something like

Function Test(TBX As MSForms.TextBox) As String
Test = TBX.Text
End Function

You can then call this with code like

MsgBox Test(Me.TextBox1)


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"asmenut" wrote in message
...
How would one go about creating a funtion that I can use a

textbox as the
argument?




Chip Pearson

Function Argument
 
You are never assigning a value to the Function, so it doesn't
return a value. You need some code in the function like

Initials = SInit


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"asmenut" wrote in message
...
Thanks. But when I plug in the function procedure, it doesn't

work (See
below)
Am I asking it to do too much?

Function Initials(SName As msForms.TextBox) As String
Dim SInit As String
Dim j As Long
Dim sLetter As String

SInit = Left(SName, 1)
j = 1
While j 0
j = InStr(j, SName, " ")
If j Then
SInit = SInint & Mid(SName, j + 1, 1)
j = j + 1
End If
Wend
End Function


"Chip Pearson" wrote:

Try something like

Function Test(TBX As MSForms.TextBox) As String
Test = TBX.Text
End Function

You can then call this with code like

MsgBox Test(Me.TextBox1)


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"asmenut" wrote in

message
...
How would one go about creating a funtion that I can use a

textbox as the
argument?








All times are GMT +1. The time now is 05:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com