Connect with Expertise | Find Experts, Get Answers, Share Insights

Simulating IntelliSense's parameter list for a function call (like MsgBox Button)

GGoldenborne's Avatar  
Join Date: Jan 2007
Posts: 3
#1: Jan 29 '10
Happy Friday, y'all!

I am creating a function and want to have IntelliSense pop down the list of valid options for a certain parameter in the same way that the MsgBox function behaves when you are typing your argument for which buttons you wish to include (such as MsgBoxStyle.OkCancel). I have done my best to search the internet but haven't found a thing which comes close to what I'm seeking. My monkeying around hasn't produced a satisfactory solution, yet, either.

A related additional thing, which I can live without but that would be nice to have, is the description of the current parameter, which appears below the function description as shown highlighted below

MsgBox (Prompt As Object, [Buttons as Microsoft.Visual Basic.MsgBoxStyle = MsgBoxStyle .DefaultButton1], [Title as Object = Nothing]) As Microsoft.VisualBasic.MsgBoxResult
Buttons:
Optional. Numeric expression that is the sum of values specifying the number and type of buttons to display, the icon style to user, the identity of the default button, and the modality of the message box. If you omit Buttons, the default is zero.
This is my first post. I'm relatively new to VB .Net. I appreciate your assistance. :)
best answer - posted by tlhintoq
You don't have to 'simulate' this. That information comes from the attributes and smart comments you assign to a parameter.

Expand|Select|Wrap|Line Numbers
  1.         /// <summary>
  2.         /// Max number of times checking the dongle can fail before quitting the app
  3.         /// </summary>
  4.         [Description("Maximum number of failures before we throw a failure event. Must be > 0"),
  5.         Category("Custom"),
  6.         DefaultValue(10),
  7.         Browsable(true)]
  8.         public int MaxFailures
  9.         {
  10.             get
  11.             {
  12.                 return maxFail;
  13.             }
  14.             set
  15.             {
  16.                 if (value > 0) maxFail = value;
  17.             }
  18.         }
  19.  
XML comments in the /// will show up in Intelesense hothelp
Attributes in the [ ] will show up in designer properties remark area.

I suggest you try it this way.
First build the complete property or method. Then go one line above it and type ///
Intelesense will then stub in XML tags for description, parameters and return. All you have to do is complete the descriptions.

You can define your own attributes, or use the stock ones like 'Description'.
http://msdn.microsoft.com/en-us/libr...attribute.aspx

tlhintoq's Avatar
E
C
 
Join Date: Mar 2008
Location: Arizona, USA
Posts: 3,476
#2: Jan 29 '10

re: Simulating IntelliSense's parameter list for a function call (like MsgBox Button)


You don't have to 'simulate' this. That information comes from the attributes and smart comments you assign to a parameter.

Expand|Select|Wrap|Line Numbers
  1.         /// <summary>
  2.         /// Max number of times checking the dongle can fail before quitting the app
  3.         /// </summary>
  4.         [Description("Maximum number of failures before we throw a failure event. Must be > 0"),
  5.         Category("Custom"),
  6.         DefaultValue(10),
  7.         Browsable(true)]
  8.         public int MaxFailures
  9.         {
  10.             get
  11.             {
  12.                 return maxFail;
  13.             }
  14.             set
  15.             {
  16.                 if (value > 0) maxFail = value;
  17.             }
  18.         }
  19.  
XML comments in the /// will show up in Intelesense hothelp
Attributes in the [ ] will show up in designer properties remark area.

I suggest you try it this way.
First build the complete property or method. Then go one line above it and type ///
Intelesense will then stub in XML tags for description, parameters and return. All you have to do is complete the descriptions.

You can define your own attributes, or use the stock ones like 'Description'.
http://msdn.microsoft.com/en-us/libr...attribute.aspx
GGoldenborne's Avatar  
Join Date: Jan 2007
Posts: 3
#3: Jan 29 '10

re: Simulating IntelliSense's parameter list for a function call (like MsgBox Button)


Thanks for the help! I'm on the right track now. (I'm just working out the differences a little from your example which is some flavor of C, I think, to VB.) I really appreciate it. You've made my day!
 
Join Date: Jun 2010
Posts: 2
#4: Jun 13 '10

re: Simulating IntelliSense's parameter list for a function call (like MsgBox Button)


GGoldenborne:
Can you show me how to do it, I still don't get it?
I don't understand the C example :-(

:-)
 
Join Date: Jun 2010
Posts: 2
#5: Jun 13 '10

re: Simulating IntelliSense's parameter list for a function call (like MsgBox Button)


Arghhhh, GOT IT!

For others: You make XML comments in vb.net using '''

Example:
''' <summary>
''' This is a test comment
''' </summary>
''' <param name="Str1">Type in some text</param>
''' <param name="Str2">Type in some more text</param>
''' <returns></returns>
''' <remarks></remarks>
Function TEST(ByVal Str1 As String, ByVal Str2 As String) As String
Return Str1 And Str2
End Function
GGoldenborne's Avatar  
Join Date: Jan 2007
Posts: 3
#6: Jun 14 '10

re: Simulating IntelliSense's parameter list for a function call (like MsgBox Button)


That's exactly correct, BeeBob12! Good work. :-)
Reply