Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Function line syntax error

Status
Not open for further replies.

Lourry

Technical User
Jul 25, 2003
84
CA
What is wrong with the following function line? It works in A2K and AXP but now A97 which is what I am using...

It keep saying there's a syntax error:

Private Function Convert(str As String) As Long()
.
.
.
End Function

Thanks in advance!
-Lory
 
This returns a function Long().
You probably mean to say that it returns a Long Integer as in:

Private Function Convert(str As String) As Long
 
Actually, I would like it to return an array which is of Long datatype.

What is the syntax for array as return values?

Thanks again!
 
I believe you have the correct syntax for access 2000+ versions. Think it became available in that version. I'd suggest returning a delimited string in stead, and "split" it after the function call. Don't think the split function is available in access 97 either, but this faq offers some functions to replace the "missing" functions faq705-4342.

Roy-Vidar
 
You could also try returning a Variant which masks the fact that it's array of longs.

Good Luck
--------------
To get the most from your Tek-Tips experience, please read FAQ181-2886
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Actually I combined the function and the sub that calls the function into one sub since that won't have any problems passing long arrays.

Thanks for the replies!
 
How are ya Lourry . . . . .

[blue]CajunCenturion[/blue] is right. Not only can variants accept arrays, but any data type.

Code:
[blue]Public Sub GetArray()
   Dim qAry As Variant, N As Integer   
   
   qAry = MakeArray()
   
   For N = 0 To 2
      Debug.Print qAry(N)
   Next
End Sub

Public Function MakeArray() As Variant
   Dim Ary(2) As String
   
   Ary(0) = "Good"
   Ary(1) = "Old"
   Ary(2) = "Time"
   
   MakeArray = Ary()
End Function[/blue]

Calvin.gif
See Ya! . . . . . .
 
Lourry . . . . .

Wrong example. Here's example using array of long data type:
Code:
[blue]Public Sub GetArray()
   Dim qAry As Variant, N As Integer, hld As Variant
   
   qAry = MakeArray()
   
   For N = 0 To 2
      'VarType(qAry(N)) = 3 = Long Data Type
      Debug.Print VarType(qAry(N)) & " " & qAry(N)
   Next
End Sub

Public Function MakeArray() As Variant
   Dim Ary(2) As Long
   
   Ary(0) = 1000
   Ary(1) = 2000
   Ary(2) = 3000
   
   MakeArray = Ary()
End Function[/blue]

Calvin.gif
See Ya! . . . . . .
 
Thanks CajunCenturion and TheAceMan1 !!

I'll keep that in mind. So the datatype variant can accept any datatype, it's sort of like a wildcard?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top