Function doesn't return an array in vb (Script) in Outlook 
Author Message
 Function doesn't return an array in vb (Script) in Outlook

Hi, I am not sure if am in the right group, because I am new in
newsgroups.

I am programing forms in Outlook with the VBA Script or VB or V
Script(I don't know for sure how this is called, because it is
different than in Excel VB). I have a function that should return an
array. But it doesn't work:

'-----------------------
Sub CommandButton1_Click()
Dim array_a(3)

array_a() = test()
MsgBox aarray(0)

End Sub

'-----------------------

Function test()
Dim array_b(3)

array_b(0) = "test1 "
array_b(1) = "test2"

test = array_b
end Function
'-----------------------

Microsoft Script De{*filter*} tels me, that in the line: 'array_a() =
test()' -> "Index out of the valid range: 'array_a'" (Index auserhalb
des gltigen Bereichs:'array_a'")
I have tried: array_a = test() too, it doesn't work. I have look for
this problem the whole www for two days. I found much help for VBA
without Outlook, but those solutions don't work here. If someone has
got a good documentation or url, that helps too. Thank you very much
for you help.

bye

Andreas P.

PS:Another question would be, why I am not able to define a variable
like "Dim a as Variant" or something like that? It works with Excel,
but not in Outlook VB. :-(



Sat, 23 Apr 2005 20:01:41 GMT  
 Function doesn't return an array in vb (Script) in Outlook

Quote:

> Hi, I am not sure if am in the right group, because I am new in
> newsgroups.

> I am programing forms in Outlook with the VBA Script or VB or V
> Script(I don't know for sure how this is called, because it is
> different than in Excel VB). I have a function that should return an
> array. But it doesn't work:

'-----------------------
Sub CommandButton1_Click()
Dim array_a 'a simple variant

array_a = test()
MsgBox array_a(0)

End Sub

'-----------------------

Function test()
Dim array_b(3)

array_b(0) = "test1 "
array_b(1) = "test2"

test = array_b
end Function
'----------------------->

Quote:
> PS:Another question would be, why I am not able to define a variable
> like "Dim a as Variant" or something like that? It works with Excel,
> but not in Outlook VB. :-(

Because all versions of Outlook *forms* use VBScript, not VBA.  VBScript
supports only Variants.

If you were writing an Outlook *macro* in OL2000 or OL2002, then that's
written in VBA.

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US



Sun, 24 Apr 2005 01:09:06 GMT  
 Function doesn't return an array in vb (Script) in Outlook

Hi Michael

[...]

Quote:

> '-----------------------
> Sub CommandButton1_Click()
> Dim array_a 'a simple variant

oh, sorry, it should be array_a(3), but it still doesn't work.

Quote:

> array_a = test()
> MsgBox array_a(0)

> End Sub

> '-----------------------

> Function test()
> Dim array_b(3)

> array_b(0) = "test1 "
> array_b(1) = "test2"

> test = array_b
> end Function
> '----------------------->

[...]

Quote:

> Because all versions of Outlook *forms* use VBScript, not VBA.  VBScript
> supports only Variants.

Does it mean, that I can't use arrays here? Do you have got an idea,
how I can write a function that returns more than one value?

Quote:

> If you were writing an Outlook *macro* in OL2000 or OL2002, then that's
> written in VBA.

OK, thanks.

Thank you for your help

bye

Andreas P.



Sun, 24 Apr 2005 16:29:33 GMT  
 Function doesn't return an array in vb (Script) in Outlook

I found the solution:

Sub CommandButton1_Click()
Dim array_a 'You don't set here anything

array_a = test() 'The dimension of array_a is set in the function test

MsgBox array_a(1)
End Sub

Function test()
Dim array_b(2)

array_b(0) = "test1 "
array_b(1) = "test2"

test = array_b

end Function

Thank you very much for your help!!

Ciao

Andi P.



Sun, 24 Apr 2005 16:36:29 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. FUNCTION doesn't return parameter value

2. parameter doesn't return value to ASP or VB

3. ActiveX call (VB to Matlab) executed but doesn't return...sometimes

4. 'Nz' Function in VB-Script

5. Array in array returned by function

6. How to return String Arrays from VB functions???

7. returning an array from a function in VB

8. One of two functions doesn't function on Windows 95 (i does on Windows NT)

9. VB doesn't accept String functions

10. API/function doesn't stop and I don't understand it :o)

11. Passing array from VB to DLL and returning array

12. OL2000 Addressproperties. PR_COURTESY_TITLE doesn't return value

 

 
Powered by phpBB® Forum Software