473,569 Members | 2,683 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing arrays to functions

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

Dim sFieldsNotRequi red(11), sFieldsWithSpec ificValues(5) As String
Dim sCaseErrMsgs As String
Dim vFieldsSpecific Values(5) As Variant
sFieldsNotRequi red(0) = "middleName "
etc...

sFieldsWithSpec ificValues(0) = "InfoRecd"
etc...

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

Dim bInfoValidates As Boolean

bInfoValidates = CheckRecordset( sSQL, sFieldsNotRequi red(),_
sFieldsWithSpec ificValues(), _
vFieldsSpecific Values(), sCaseErrMsgs)
Where
CheckRecordset is defined as:

Function CheckRecordset( sRecordsetSQL As String, sFieldsNotRequi red() As
String, _
sFieldsWithSpec ificValues() As String, _
vFieldsSpecific Values() 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, sFieldsNotRequi red,_
sFieldsWithSpec ificValues, _
vFieldsSpecific Values, sCaseErrMsgs)

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

Thanks,

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

Dim sFieldsNotRequi red(11), sFieldsWithSpec ificValues(5) As String
Dim sCaseErrMsgs As String
Dim vFieldsSpecific Values(5) As Variant < SNIP > Function CheckRecordset( sRecordsetSQL As String, sFieldsNotRequi red() As
String, _
sFieldsWithSpec ificValues() As String, _
vFieldsSpecific Values() 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 sFieldsNotRequi red(11), sFieldsWithSpec ificValues(5) As String

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

Dim sFieldsNotRequi red(11) As String, sFieldsWithSpec ificValues(5) As
String

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

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

iQA/AwUBQHdTPIechKq OuFEgEQLmNQCg+y AyMvtiaBdRK3P7C hs4M/FKj5UAoMCp
9Xp0mvfAFz52iGp 8o/+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
6562
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 from a mousedown or keydown event belonging to an array of labels i get an error saying: "tpye mismatch, array or user defined type expected". ...
5
5358
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 noticed that when a method is invoked on an object, it invokes in the context of the window that created that object. Now, when I pass an array from...
3
2275
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 structore and one member element is a char array. A function is to be created that passes the structure as a reference, along with the...
1
3435
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 realise some of the speed benefits of writing some of my routines in C++ and accessing them from my VB software. I have managed to do this with a...
3
3779
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 a variant containing an array, and interop expects a parameter of type object if you are passing a variant (you are expected to cast it to the...
3
1916
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 www.IntraRELY.com
11
8103
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 number) which is the last line of the following sub routine: ' procedure modifies elements of array and assigns ' new reference (note ByVal) Sub...
4
2494
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
1558
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 the function or does it happen globally
1
4548
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 do, but because I can't seem to locate something that is even close... I am posting... I would like to thank this community, I have received a great...
0
7698
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7673
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7970
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1213
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.