Solved

vb.net Function Parameter Comments

Posted on 2008-10-27
4
1,154 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 60

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 60

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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

696 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