Solved

vb.net Function Parameter Comments

Posted on 2008-10-27
4
1,138 Views
Last Modified: 2010-04-21
i've see people write library's that have suggested values when calling the function. i would like to do that same thing within my code but cant seem to find how to do it at all. the best i can do i defining optional parameters.

Public Function test(byval Optional Testername as String = "Jack") as String

so when i call the function i would get something on these characters

test( "intelisene would suggest Testername = Jack

but what i really want to do is to show all the valid values like

Public Function test(byval Optional Testername as Integer = 1 "1= Jack" or 2 "2=Tim" or 3 "3=Jill") as String

so when i type the call

test( "intelisense would suggest 1=jack, 2=Tim, 3=Jill so if i pass test(1) the user knows he is calling the string Jack.

I hope that makes sense, but it will make my coding more user friendly and easy to understand even if this question isn't.

Cheers
Allan


   
0
Comment
Question by:allanhutton
  • 2
  • 2
4 Comments
 
LVL 59

Accepted Solution

by:
Kevin Cross earned 500 total points
Comment Utility
I believe they are using an ENUM or similar construct where you see that.  You can make comments using the three single quotes in a row ''' that allow you to put in parameters and descriptions that you could tell users the appropriate values to pass; however, what you describe sounds more like this.

See code snippet.  When you call MySub you will be prompted to pick Jack, Tim, or Jill and while selecting the intellisense will show you Jack = 1, etc.
Public Sub MySub(ByVal value As MyInt)
 

    End Sub
 

    Public Enum MyInt As Integer

        Jack = 1

        Tim = 2

        Jill = 3

    End Enum

Open in new window

0
 

Author Comment

by:allanhutton
Comment Utility
let me give that a go looks interesting. I'll confirm soon if that what i'm trying.

cheers
Allan
0
 

Author Closing Comment

by:allanhutton
Comment Utility
the XML triple quotes was exactly what i was looking for thank.

   '''
    ''' Delete Order by specific Order Parameter
    ''' 0=All Orders
    ''' 1=Last Order
    ''' 2=Specific TTSitteOrderKey
    ''' 3=Delete range or Orders
    '''
    '''
    '''
    '''
    Function InvokeDeleteOrder(ByVal DeleteType As Integer) As Integer


can i just ask what you would use the returns and remarks xml values for?

cheers
Allan
0
 
LVL 59

Expert Comment

by:Kevin Cross
Comment Utility
<<<<<<<<
Grading Comments:
the XML triple quotes was exactly what i was looking for thank.

''' <summary>
''' Delete Order by specific Order Parameter
''' 0=All Orders
''' 1=Last Order
''' 2=Specific TTSitteOrderKey
''' 3=Delete range or Orders
''' </summary>
''' <param name="DeleteType"></param>
''' <returns></returns>

''' <remarks></remarks>
Function InvokeDeleteOrder(ByVal DeleteType As Integer) As Integer


can i just ask what you would use the returns and remarks xml values for?

cheers
Allan
>>>>>>>>

You can give more details on what your method returns.  So, I know it returns an Integer, but can put in a remark like "the number of orders deleted/affected" or whatever the Integer signifies.

The remarks allow you to add additional comments beyond the summary from my understanding.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now