Richard
Tue Jul 08 11:25:12 CDT 2008
"Meat" <Meat@discussions.microsoft.com> wrote in message
news:B5DE587E-1B5C-4FFE-967F-EB2BE3C87B2D@microsoft.com...
> Yes, that's what I did, I'm sorry for the error in this post.
>
> I don't know why but the function returns absolutely nothing.
>
> "Pegasus (MVP)" wrote:
>
>>
>> "Meat" <Meat@discussions.microsoft.com> wrote in message
>> news:23F81DFD-D722-4560-986D-620D31EC1046@microsoft.com...
>> > Hello,
>> >
>> > I want to return a value with a function. I call the function like
>> > this :
>> >
>> > NameVar = function(NameVar2)
>> >
>> > The code of the function looks like this :
>> >
>> > function(NameVar2)
>> >
>> > If NameVar2 = statement Then
>> > function = 0
>> > Else
>> > function = 1
>> > End if
>> >
>> > After I called the function, the variable NameVar contains absolutelly
>> > nothing. What am I doing wrong?
>> >
>> > Thank you.
>>
>> "function" is a reserved name. Furthermore it is not a good
>> idea to use the same variable name in the main program
>> and in the function. Try this:
>>
>> NameVar = Test(NameVar2)
>>
>> function Test(MyString)
>> If MyString = "some string" Then
>> Test = 0
>> Else
>> Test = 1
>> End if
>> end function
>>
>>
>>
Just to clarify, you don't need to post your actual code. It may be very
long or have confidential information. But you should be able to post code
that duplicates the problem, so we can run it. If you cannot duplicate the
problem in a short snippet, then most likely there is something else wrong
in your program. For example, you may be using "On Error Resume Next" and an
error earlier in the program is messing things up. If we cannot duplicate
the problem, the only recourse is for you post the actual code.
--
Richard Mueller
MVP Directory Services
Hilltop Lab -
http://www.rlmueller.net
--