473,320 Members | 1,900 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Passing arrays to functions

Hi,
I'm having trouble passing an array to a function,
like this:

Dim sFieldsNotRequired(11), sFieldsWithSpecificValues(5) As String
Dim sCaseErrMsgs As String
Dim vFieldsSpecificValues(5) As Variant
sFieldsNotRequired(0) = "middleName"
etc...

sFieldsWithSpecificValues(0) = "InfoRecd"
etc...

vFieldsSpecificValues(0) = True
etc...
Dim sCaseSQL As String
sRecSQL = "SELECT * from table WHERE ID = " & iID

Dim bInfoValidates As Boolean

bInfoValidates = CheckRecordset(sSQL, sFieldsNotRequired(),_
sFieldsWithSpecificValues(), _
vFieldsSpecificValues(), sCaseErrMsgs)
Where
CheckRecordset is defined as:

Function CheckRecordset(sRecordsetSQL As String, sFieldsNotRequired() As
String, _
sFieldsWithSpecificValues() As String, _
vFieldsSpecificValues() As Variant,
sErrMessages As String) As Boolean

The trouble is I get the error:

type mismatch array or user-defined type expected

This is also true when I call the function as

bInfoValidates = CheckRecordset(sSQL, sFieldsNotRequired,_
sFieldsWithSpecificValues, _
vFieldsSpecificValues, sCaseErrMsgs)

can somebody give me some clues as to what's going on?

Thanks,

Eric
Nov 12 '05 #1
1 1879
Eric Ellsworth wrote:
Hi,
I'm having trouble passing an array to a function,
like this:

Dim sFieldsNotRequired(11), sFieldsWithSpecificValues(5) As String
Dim sCaseErrMsgs As String
Dim vFieldsSpecificValues(5) As Variant < SNIP > Function CheckRecordset(sRecordsetSQL As String, sFieldsNotRequired() As
String, _
sFieldsWithSpecificValues() As String, _
vFieldsSpecificValues() As Variant, sErrMessages
As String) As Boolean

The trouble is I get the error:
type mismatch array or user-defined type expected
This is also true when I call the function as

< SNIP >

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

This Dim:

Dim sFieldsNotRequired(11), sFieldsWithSpecificValues(5) As String

Sets the array sFieldsNotRequired() to a Variant array, not a String
array. This is correct declaration:

Dim sFieldsNotRequired(11) As String, sFieldsWithSpecificValues(5) As
String

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQHdTPIechKqOuFEgEQLmNQCg+yAyMvtiaBdRK3P7Chs4M/FKj5UAoMCp
9Xp0mvfAFz52iGp8o/+yztiB
=ps64
-----END PGP SIGNATURE-----

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Kevin | last post by:
Hi i'm having a problem passing an arrays of controls on a form to a function or sub. I can use this code for any datatype but when i change 'long' to 'label' in the public sub and i call the sub...
5
by: Andy Fish | last post by:
Hi, I have a HTML page with javascript in it which pops up another HTML page. I can pass simple variables fairly freely between the two pages. I can pass objects between them two, and I have...
3
by: Steven Taylor | last post by:
Hope someone can assist. I'm trying to answer a book question. I'm going around in circles in relation to 'pointer-to-char'. Object : A short program is to be created, which involves a...
1
by: Kurt Richardson | last post by:
Hi all Sorry to bother you with what is probably a really trivial question for you C++ experts. My programming skill are pretty amateur, but I'm pretty good at VB.NET. However, I'm wanting to...
3
by: Mark | last post by:
Hi From what I understand, you can pass arrays from classic ASP to .NET using interop, but you have to change the type of the.NET parameter to object. This seems to be because classic ASP passes...
3
by: IntraRELY | last post by:
I have the following function, Notice how I am passing the dateInterval as a string. What is the correct way to pass "DateInterval.Year" as a variable to a function? TIA, Steve Wofford...
11
by: John Pass | last post by:
Hi, In the attached example, I do understand that the references are not changed if an array is passed by Val. What I do not understand is the result of line 99 (If one can find this by line...
4
by: Christian Maier | last post by:
Hi After surfing a while I have still trouble with this array thing. I have the following function and recive a Segmentation fault, how must I code this right?? Thanks Christian Maier
2
by: viggu | last post by:
how to pass arrays into the function and what is the use of functions.what do you mean by a modification of the array values in the function and does the modification of the values occur only inside...
1
by: Fizzics | last post by:
This is my first post here at Bytes. I have been trolling it, mostly with the help of Google searches, for some time now. I have done about all of the searching and reading that I really know how to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.