Solved

vb.net Function Parameter Comments

Posted on 2008-10-27
4
1,141 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
ID: 22813443
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
ID: 22814437
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
ID: 31510420
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
ID: 22815162
<<<<<<<<
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

914 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

21 Experts available now in Live!

Get 1:1 Help Now