how to figure different variations of a method (ex. PadLeft() )

  • Thread starter Thread starter vbDavidC
  • Start date Start date
V

vbDavidC

Hi,

Does Intellisense show the differen
I am using VB2005 and was reading a VB book and came across the
PadLeft method and I wanted to understand how it works.

m_MyString = m_strTime.PadLeft(4,Convert.ToChar("0"))

I understand (perfectly) how this works but since I am new to this
language I wanted to make sure I understood it properly. If I use
Intellisense or use MS Help it shows it basically shows the PadLeft
with one parameter (totalwidth) and includes the statement:

'Right-aligns the characters in this instance, padding with spaces on
the left for a specified total length.'

I thought that Intellisense would show me a + sign that would allow me
to see different variations but in this case it did not do that. If I
check Help (F1) it shows 2 variations, although it seems that the
first time I checked Help it only showed the 1 variation. :)

Being in a hurry I might just use this shown example and never use
these other variations.

thanks for any help, David
 
vbDavidC said:
Hi,

Does Intellisense show the differen
I am using VB2005 and was reading a VB book and came across the
PadLeft method and I wanted to understand how it works.

m_MyString = m_strTime.PadLeft(4,Convert.ToChar("0"))

I understand (perfectly) how this works but since I am new to this
language I wanted to make sure I understood it properly. If I use
Intellisense or use MS Help it shows it basically shows the PadLeft
with one parameter (totalwidth) and includes the statement:

'Right-aligns the characters in this instance, padding with spaces on
the left for a specified total length.'

I thought that Intellisense would show me a + sign that would allow me
to see different variations but in this case it did not do that. If I
check Help (F1) it shows 2 variations, although it seems that the
first time I checked Help it only showed the 1 variation. :)

Being in a hurry I might just use this shown example and never use
these other variations.

thanks for any help, David

In VB 2008, if I type

m_MyString = m_strTime.PadLeft(

I see http://freenet-homepage.de/armin.zingler/VB2009-03-18.PNG

If I press ESC once, the lower box closes. Using the arrow up/down keys, I
can scroll through the overloaded method versions in the "parameters info"
box. The more parameters I type, the more the overload list is narrowed down
to match the parameter types entered. IIRC the latter feature has been
introduced in VB 2008.


Armin
 
Hi,

Does Intellisense show the differen
I am using VB2005 and was reading a VB book and came across the
PadLeft method and I wanted to understand how it works.

m_MyString = m_strTime.PadLeft(4,Convert.ToChar("0"))

I understand (perfectly) how this works but since I am new to this
language I wanted to make sure I understood it properly. If I use
Intellisense or use MS Help it shows it basically shows the PadLeft
with one parameter (totalwidth) and includes the statement:

'Right-aligns the characters in this instance, padding with spaces on
the left for a specified total length.'

I thought that Intellisense would show me a + sign that would allow me
to see different variations but in this case it did not do that. If I
check Help (F1) it shows 2 variations, although it seems that the
first time I checked Help it only showed the 1 variation. :)

Being in a hurry I might just use this shown example and never use
these other variations.

thanks for any help, David

I am guessing that the m_strTime variable is of type String.

When I do this, Intellisense shows something like:
1 of 2 PadLeft(totalWidth As String) As String

If I click on the little down arrow the right of the 2 I see:

2 of 2 PadLeft(totalWidth As String, paddingChar As Char) As String
 
Both of you are correct. However, the reason I did not see the
different variations was because of the following:

I was editing some existing code that already had the padleft method
which had the 2 parameters (totalwidth, padding char).

I moved my cursor after the period and before the (P) in Padleft. I
backspaced to remove the period, typed another period to show
Intellisense. Intellisense defaulted to Padleft and a little yellow
tip showing only the first usage (1 parameter: totalwidth). If I type
the command new or edit it differently the different usages show up.

thanks, David
 
m_MyString = m_strTime.PadLeft(4,Convert.ToChar("0"))

Just as an aside, this line can be shortened to:

m_MyString = m_strTime.PadLeft(4, "0"c)

which looks a little cleaner to me.

Chris
 
Back
Top