View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_5_] Bob Phillips[_5_] is offline
external usenet poster
 
Posts: 620
Default Direct manipulation of TextBox

Mike,

If you really want to do that, try this
Function a_test(sSource As String, ByRef sTarget As MSForms.TextBox) As
Boolean
sTarget.Value = Left(sSource, 1)
a_test = True
End Function


Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If a_test(TextBox1.Value, TextBox2) Then
'do your other stuff
End If
End Sub


--
HTH

-------

Bob Phillips
... looking out across Poole Harbour to the Purbecks


"Mike NG" wrote in message
...
On Sat, 12 Jul 2003 at 13:40:34, Bob Phillips (Bob Phillips
) wrote:
Mike,

You should and you can. But I think you are misunderstanding how to use
functions. The function should return the result of the manipulation, to

try
and manipulate an argument and return a result is a bit obtuse. This

works
fine

Function a_test(sSource As String) As String
a_test = Left(sSource, 1)
End Function


Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
TextBox2.Value = a_test(TextBox1)
End Sub

Cheers Bob

While this is going to work, what I was trying to achieve by passing
parameters back and a function return code, was so that I could do
something like

If Not a_test(TextBo1, TextBox2) Then Goto ....

I guess I will end up with the same result, a function call and an If
statement, but at least I've avoided having to declare an intermediate
variable
--
Mike