473,788 Members | 2,726 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing Optional Arguments into an Array Function

I want to pass optional arguments to build up varios strings, is this
possible?

look at arrTBL(1,3) in the code below:

=============== =============== =============

Public Function arrTBL(Optional ByVal DataSetName As String = "") As
String(,)
Dim DSN As String = DataSetName

arrTBL(1, 1) = "UP_" & Session("mCallC entreID") & "_Results_Daily "
arrTBL(1, 2) = "DailyCallS t"
arrTBL(1, 3) = "INSERT INTO " & arrTBL(1, 1) & "SELECT " & DSN &
".field1 FROM " & DSN & ";"

End function

=============== =============== =============== =

I would like to be able to do this, but the other arrays dont like it,
too many arguments etc..

Is there a way round this?
Nov 21 '05 #1
3 4787
Winshent,
VB.NET is trying to recursively call your routine, rather then treat arrTBL
as a variable.

To avoid the ambiguity this is causing I would define a variable for the
return value, use this value, then return it.

Something like:
Public Function arrTBL(Optional ByVal DataSetName As String = "") As
String(,)
Dim value(1,3) As String
Dim DSN As String = DataSetName
value(1, 1) = "UP_" & Session("mCallC entreID") & "_Results_Daily "
value(1, 2) = "DailyCallS t"
value(1, 3) = "INSERT INTO " & value(1, 1) & "SELECT " & DSN & ".field1 FROM " & DSN & ";"
Return value
End function
NOTE: The optional parameter has nothing to do with it, try the following:

Public Function arrTBL(ByVal x As Integer, ByVal y As Integer) As
String(,)

arrTBL(1,1) = "Hello!"

End Function

"arrTBL(1,1 )" is treated as a recursive call so you get an error about
"Expression is a value and therefore cannot be the target of an assignment".

Hope this helps
Jay
"Winshent" <wi************ *@yahoo.co.uk> wrote in message
news:f5******** *************** ***@posting.goo gle.com...I want to pass optional arguments to build up varios strings, is this
possible?

look at arrTBL(1,3) in the code below:

=============== =============== =============

Public Function arrTBL(Optional ByVal DataSetName As String = "") As
String(,)
Dim DSN As String = DataSetName

arrTBL(1, 1) = "UP_" & Session("mCallC entreID") & "_Results_Daily "
arrTBL(1, 2) = "DailyCallS t"
arrTBL(1, 3) = "INSERT INTO " & arrTBL(1, 1) & "SELECT " & DSN &
".field1 FROM " & DSN & ";"

End function

=============== =============== =============== =

I would like to be able to do this, but the other arrays dont like it,
too many arguments etc..

Is there a way round this?

Nov 21 '05 #2
Whinshent,

I can do it in this way, the other way I did not try.
\\\
Dim DSN As String = "whatever"
Dim arrTbl As New ArrayList
arrTbl.Add(New ArrayList)
DirectCast(arrT bl(0), ArrayList).Add( "UP_" & "mCallCentr eID" _
& "_Results_Daily ")
DirectCast(arrT bl(0), ArrayList).Add( "DailyCallS t")
DirectCast(arrT bl(0), ArrayList).Add( "INSERT INTO " & _
DirectCast(arrT bl(0), ArrayList)(0).T oString & _
"SELECT " & DSN & ".field1 FROM " & DSN & ";")
MessageBox.Show (DirectCast(arr Tbl(0), ArrayList)(2).T oString)
///

I hope this helps?

Cor

"Winshent" <wi************ *@yahoo.co.uk>
I want to pass optional arguments to build up varios strings, is this
possible?

look at arrTBL(1,3) in the code below:

=============== =============== =============

Public Function arrTBL(Optional ByVal DataSetName As String = "") As
String(,)
Dim DSN As String = DataSetName

arrTBL(1, 1) = "UP_" & Session("mCallC entreID") & "_Results_Daily "
arrTBL(1, 2) = "DailyCallS t"
arrTBL(1, 3) = "INSERT INTO " & arrTBL(1, 1) & "SELECT " & DSN &
".field1 FROM " & DSN & ";"

End function

=============== =============== =============== =

I would like to be able to do this, but the other arrays dont like it,
too many arguments etc..

Is there a way round this?

Nov 21 '05 #3
Jay, i have used your method and it seems to have worked nicely..

Thanks to you both for responding.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #4

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

Similar topics

3
14952
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) { document.images.src = eval("mt" +menu+ ".src") } alert("imgOff_hidemenu"); hideMenu=setTimeout('Hide(menu,num)',500);
58
10181
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of code... TCHAR myArray; DoStuff(myArray);
2
1566
by: windandwaves | last post by:
Hi Folk I have the following function var a = new Array(4); a = new Array(45); //status (on or off) a = new Array(45); //name of the region a = new Array(45); //on mouse over a = new Array(45); //on mouse out a = false;
39
7665
by: Mike MacSween | last post by:
Just spent a happy 10 mins trying to understand a function I wrote sometime ago. Then remembered that arguments are passed by reference, by default. Does the fact that this slowed me down indicate: a) That I don't know enough b) Passing arguments by ref is bad
17
3604
by: Charles Sullivan | last post by:
The library function 'qsort' is declared thus: void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *)); If in my code I write: int cmp_fcn(...); int (*fcmp)() = &cmp_fcn; qsort(..., fcmp); then everything works. But if instead I code qsort as:
2
15128
by: Tobias Olbort | last post by:
Hello, i've a outer function, which takes a params-array as a parameter. I want to pass this array to inner function with a params-array (e. g. string.format). When i've passed an integer to the outer function, the string.format sets the string-value "System.Object" at the position of {0}. How can i get it work, so that all my values, passed to the outer
16
4064
by: ad | last post by:
Does C#2.0 support optional parameters like VB.NET: Function MyFunction(Optional ByVal isCenter As Boolean = False)
7
1984
by: Bonzo | last post by:
>From within a function, I want to pass a/some parameters to another function, AND all arguments, passed into this function. e.g. function firstFunction(){ //this function may have been passed, 0, 1, or n arguments... ... //call another function... var someCalculatedValue = 'someValue';
2
4622
by: Mary Pegg | last post by:
No point re-inventing the wheel, so thought I'd see if anybody's got some good example code kicking around. (Please excuse trivial syntactical errors, it's all coming off the top of my head). Say I have a function thus: function munge($a) { return ($a * 2);
0
9498
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10366
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10175
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10112
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8993
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4070
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
3
2894
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.