Solved

vb.net Function Parameter Comments

Posted on 2008-10-27
4
1,147 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

786 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