subroutine with fixed list of parameter

  • Thread starter Thread starter vipul DotNet
  • Start date Start date
V

vipul DotNet

hi friend,

I have a function which can accept 2 parameters ,
one as any double value
second as "Y" or "N"

public sub abc(byval dblvalue as double,byval strvalue as string)

end sub
I want the subroutine to accept only "Y" or "N" as parameter else should
give error at design time when the subroutine is been used by other
programmers

how is this possible ?
I would also like to give description of the parameters when the user try to
enter the
parameters as we see in intellisence.

do we have to use reflection package ??

please give me the soln..
waiting !!

thanks

vipul
 
vipul DotNet said:
hi friend,

I have a function which can accept 2 parameters ,
one as any double value
second as "Y" or "N"

public sub abc(byval dblvalue as double,byval strvalue as string)

end sub
I want the subroutine to accept only "Y" or "N" as parameter else
should give error at design time when the subroutine is been used by
other programmers

how is this possible ?

I would also like to give description of the parameters when the user
try to enter the
parameters as we see in intellisence.



public sub abc(byval dblvalue as double,byval value as BOOLEAN)

Convert value to a string only when necessary.

do we have to use reflection package ??


No.
 
thanks but my requirement is ...

what if i have to allow the programmer who is using my subroutine
should enter only the values out of which i provide to him

public sub abc(byval dblvalue as double,byval strvalue as string)

say i want the values from my list say strvalues=
"america"
"australia"
"newzeland"
"England"
and no other value in the second parameter ,which he should be able to
select by intellisence.


vipul
 
vipul DotNet said:
thanks but my requirement is ...

what if i have to allow the programmer who is using my subroutine
should enter only the values out of which i provide to him

public sub abc(byval dblvalue as double,byval strvalue as string)

say i want the values from my list say strvalues=
"america"
"australia"
"newzeland"
"England"
and no other value in the second parameter ,which he should be able
to select by intellisence.

Class Country
Public Shared ReadOnly America As New Country("America")
Public Shared ReadOnly Australia As New Country("Australia")

Public ReadOnly Name As String
Private Sub New(ByVal Name As String)
Me.Name = Name
End Sub
End Class


Procedure:
public sub abc(byval dblvalue as double,byval strvalue as COUNTRY)

Call:
abc(4711, Country.America)

Not "Country", but "America" will be listed when typing "Country."



- OR -

Enum Countries
America
Australia
End Enum

public sub abc(byval dblvalue as double,byval strvalue as Countries)
 
Back
Top