Re: What is the syntax for function text parameters in VBA (Excel

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Jocken <Joc...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote...
So I tried that like so:

Function CONTAINS(within, test)

Dim within As String
Dim test As String

the compiler complains about a duplicate declaration.
....

Online help is your friend. Using it, you can find answers to problems
that could take days of back & forth with newsgroups postings.

Searching VBA help for the term Function does produce a lot of chaff,
but also the topic titled 'Function Statement'. The Example link in
that topic shows several examples, the first of which is:


Function CalculateSquareRoot(NumberArg As Double) As Double
If NumberArg < 0 Then ' Evaluate argument.
Exit Function ' Exit to calling procedure.
Else
CalculateSquareRoot = Sqr(NumberArg) ' Return square root.
End If
End Function


which shows that the proper syntax requires putting the type
declaration in the function's argument list.

what I want to say is "Function CONTAINS(String within,
String test)"; All I need is for VBA to set up a function that
expects two String-type parameters and does calculations with them.

And the online help examples show that your syntax is wrong. There are
many examples of proper syntax in online help. In MSFT BASIC dialects,
types are specified by APPENDING 'As' followed by the type name AFTER
the variable name.

I miss Java... *tear
....

Most definitely VB* isn't Java, but you can't expect any language that
doesn't trace its ancestry to C to use C-like syntax. At some point
you have to sneak a peak at the language docs.

.



Relevant Pages

  • Re: positioning input box
    ... It acted as if the string I used for the ... > Sub GetInput() ... The info in my books and online help ... > Steve Rindsberg, PPT MVP ...
    (microsoft.public.powerpoint)
  • Re: == INSTEAD OF EXACT?
    ... Likewise my online help isn't enabled, here's a copy of my built in help ... EXACT is case-sensitive but ignores formatting differences. ... Text2 is the second text string. ... David Biddulph wrote: ...
    (microsoft.public.excel.misc)
  • Reading array of string returned by Get method
    ... any supporting material (books, online help, etc). ... I'm trying to read an array of string embedded in a VARIANT returned ... write any consistent code. ...
    (microsoft.public.win32.programmer.networks)
  • Reading array of string returned by Get method
    ... any supporting material (books, online help, etc). ... I'm trying to read an array of string embedded in a VARIANT returned ... write any consistent code. ...
    (microsoft.public.win32.programmer.wmi)
  • Re: VBA - Passing a FUNCTION as an Argument
    ... The closest you can get ... Function DerFunction(F As String, Point1,Point2) ... I want to> create a VBA function that calculates the derivative of> another function between two points. ... > What is the proper syntax, ...
    (microsoft.public.excel.programming)