473,398 Members | 2,404 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,398 software developers and data experts.

Enumerate argument list

Anyone know of a way to enumerate the argument list of a function in
VB.NET.

For example I have a Function add_user (u_id AS INT, u_first_name AS
VARCHAR(50), u_last_name AS VARCHAR(50)).

I want to be able to do something like this:

For each argument in add_user.argumentlist
Select Case argument.name
Case u_id
'Do This
Case u_first_name
'Do this
ETC.
Next argument

Sep 16 '05 #1
4 1635
Looks rather like SQL code than VB.NET code...

Arguments are always there. Why not doing simply :
' Do This for u_id
' Do This for u_first_name
' Do This for u_last_name

Overall I don't really uderstand what you are trying to do...
(you could perhaps add them in an ArrayList or something similar if you
really need to).

--
Patrice

<di**********@gmail.com> a écrit dans le message de
news:11**********************@g43g2000cwa.googlegr oups.com...
Anyone know of a way to enumerate the argument list of a function in
VB.NET.

For example I have a Function add_user (u_id AS INT, u_first_name AS
VARCHAR(50), u_last_name AS VARCHAR(50)).

I want to be able to do something like this:

For each argument in add_user.argumentlist
Select Case argument.name
Case u_id
'Do This
Case u_first_name
'Do this
ETC.
Next argument

Sep 16 '05 #2
Hi,

You can do that, example below:
Private Sub WeirdFunction(ByVal arg1 As Integer, ByVal arg2 As Integer,
ByVal arg3 As Integer)

Dim stFrame As New StackFrame

Dim currentMethod As System.Reflection.MethodBase = stFrame.GetMethod()

Dim currentParameters() As System.Reflection.ParameterInfo =
currentMethod.GetParameters()

For Each param As System.Reflection.ParameterInfo In currentParameters

Select Case param.Name

Case "arg1"

' do whatever

End Select

Next

End Sub

<di**********@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Anyone know of a way to enumerate the argument list of a function in
VB.NET.

For example I have a Function add_user (u_id AS INT, u_first_name AS
VARCHAR(50), u_last_name AS VARCHAR(50)).

I want to be able to do something like this:

For each argument in add_user.argumentlist
Select Case argument.name
Case u_id
'Do This
Case u_first_name
'Do this
ETC.
Next argument

Sep 16 '05 #3
Ok I have succesfully gotten my list of paramaters but now I want to
assign values to the paramaters and send the list back to the
funcitons.

Here is what I have now...

Dim typFunction As Type = GetType(SecLink.Db.StoredProcedures)
Dim infoFunction As MethodInfo =
typFunction.GetMethod("spUpdUser_Command")
Dim prmArgument As ParameterInfo
Dim strArgList As String
For Each prmArgument In infoFunction.GetParameters
'Find the correct value from the dataset
If InStr(prmArgument.Name.ToString, "edit_user") > 0 Then
strArgList = strArgList & Session("edit_user")
Else
strArgList = strArgList &
dsUser.Tables(0).Rows(0).Item(prmArgument.Name.ToS tring) & ","
End If
Next

clsDB.StoredProcedures.spUpdUser_Command(strArgLis t)

So I can build a string of values that can be passed back to the
spUpdUser_Command but if I try to pass it just as a string VB.NET does
not like this. It reads strArgList as just being the value for the
first argument the function accepts. I need to find a way to set the
paramaters to a value and then execute the function.

Sep 19 '05 #4
OK this works but now I need to set the paramaters to a value and then
call the funciton with the values I set.

Here is what I have...

Dim typFunction As Type = GetType(Primax.SecLink.Db.StoredProcedures)
Dim infoFunction As MethodInfo =
typFunction.GetMethod("spUpdUser_Command")
Dim prmArgument As ParameterInfo
Dim strArgList As String
For Each prmArgument In infoFunction.GetParameters
'Find the correct value from the dataset
If InStr(prmArgument.Name.ToString, "edit_user") > 0 Then
strArgList = strArgList & Session("edit_user")
Else
strArgList = strArgList &
dsUser.Tables(0).Rows(0).Item(prmArgument.Name.ToS tring) & ","
End If
Next

clsDB.StoredProcedures.spUpdUser_Command(strArgLis t)

When I pass strArgList to my function (spUpdUser_Command) the project
won't compile.

Sep 19 '05 #5

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

Similar topics

5
by: Pekka Niiranen | last post by:
Hi, I have Perl code looping thru lines in the file: line: while (<INFILE>) { ... $_ = do something ... if (/#START/) { # Start inner loop
2
by: tricky one | last post by:
Anyone know of a way to enumerate the argument list of a function in VB.NET. For example I have a Function add_user (u_id AS INT, u_first_name AS VARCHAR(50), u_last_name AS VARCHAR(50)). I...
4
by: dickson.matt | last post by:
Anyone know of a way to enumerate the argument list of a function in VB.NET. For example I have a Function add_user (u_id AS INT, u_first_name AS VARCHAR(50), u_last_name AS VARCHAR(50)). I...
1
by: smichr | last post by:
I see that there is a thread of a similar topic that was posted recently ( enumerate with a start index ) but thought I would start a new thread since what I am suggesting is a little different. ...
2
by: eight02645999 | last post by:
hi, i am using python 2.1. Can i use the code below to simulate the enumerate() function in 2.3? If not, how to simulate in 2.1? thanks from __future__ import generators def...
21
by: James Stroud | last post by:
I think that it would be handy for enumerate to behave as such: def enumerate(itrbl, start=0, step=1): i = start for it in itrbl: yield (i, it) i += step This allows much more flexibility...
12
by: Danny Colligan | last post by:
In the following code snippet, I attempt to assign 10 to every index in the list a and fail because when I try to assign number to 10, number is a deep copy of the ith index (is this statement...
7
by: Nikhil | last post by:
Hi, I am reading a file with readlines method of the filepointer object returned by the open function. Along with reading the lines, I also need to know which line number of the file is read in...
3
by: Eric_Dexter | last post by:
I am trying to take some data in file that looks like this command colnum_1 columnum_2 and look for the command and then cange the value in the collum(word) number indicated. I am under...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.