<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://www.logicwiki.co.uk/index.php?action=history&amp;feed=atom&amp;title=Write_an_Extension_Method_-_Visual_Basic</id>
		<title>Write an Extension Method - Visual Basic - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://www.logicwiki.co.uk/index.php?action=history&amp;feed=atom&amp;title=Write_an_Extension_Method_-_Visual_Basic"/>
		<link rel="alternate" type="text/html" href="https://www.logicwiki.co.uk/index.php?title=Write_an_Extension_Method_-_Visual_Basic&amp;action=history"/>
		<updated>2026-10-03T16:29:10Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.26.2</generator>

	<entry>
		<id>https://www.logicwiki.co.uk/index.php?title=Write_an_Extension_Method_-_Visual_Basic&amp;diff=823&amp;oldid=prev</id>
		<title>Dt1nh6: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://www.logicwiki.co.uk/index.php?title=Write_an_Extension_Method_-_Visual_Basic&amp;diff=823&amp;oldid=prev"/>
				<updated>2016-05-09T13:27:59Z</updated>
		
		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;tr style='vertical-align: top;' lang='en'&gt;
				&lt;td colspan='1' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='1' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 13:27, 9 May 2016&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan='2' style='text-align: center;' lang='en'&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Dt1nh6</name></author>	</entry>

	<entry>
		<id>https://www.logicwiki.co.uk/index.php?title=Write_an_Extension_Method_-_Visual_Basic&amp;diff=822&amp;oldid=prev</id>
		<title>Macrop at 08:38, 11 March 2015</title>
		<link rel="alternate" type="text/html" href="https://www.logicwiki.co.uk/index.php?title=Write_an_Extension_Method_-_Visual_Basic&amp;diff=822&amp;oldid=prev"/>
				<updated>2015-03-11T08:38:43Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Category:VB.NET]]&lt;br /&gt;
&lt;br /&gt;
Extension methods enable you to add methods to an existing class. The extension method can be called as if it were an instance of that class.&lt;br /&gt;
== To define an extension method ==&lt;br /&gt;
* Open a new or existing Visual Basic application in Visual Studio.&lt;br /&gt;
* At the top of the file in which you want to define an extension method, include the following import statement:&lt;br /&gt;
 Imports System.Runtime.CompilerServices&lt;br /&gt;
* Within a module in your new or existing application, begin the method definition with the extension attribute:&lt;br /&gt;
 &amp;lt;Extension()&amp;gt;&lt;br /&gt;
* Declare your method in the ordinary way, except that the type of the first parameter must be the data type you want to extend.&lt;br /&gt;
 &amp;lt;Extension()&amp;gt; &lt;br /&gt;
 Public Sub subName (ByVal para1 As ExtendedType, &amp;lt;other parameters&amp;gt;)&lt;br /&gt;
      ' &amp;lt; Body of the method &amp;gt;&lt;br /&gt;
 End Sub&lt;br /&gt;
== Example ==&lt;br /&gt;
The following example declares an extension method in module StringExtensions. A second module, Module1, imports StringExtensions and calls the method. The extension method must be in scope when it is called. Extension method PrintAndPunctuate extends the String class with a method that displays the string instance followed by a string of punctuation symbols sent in as a parameter.&lt;br /&gt;
&lt;br /&gt;
 ' Declarations will typically be in a separate module.&lt;br /&gt;
 Imports System.Runtime.CompilerServices &lt;br /&gt;
 &lt;br /&gt;
 Module StringExtensions&lt;br /&gt;
     &amp;lt;Extension()&amp;gt; &lt;br /&gt;
     Public Sub PrintAndPunctuate(ByVal aString As String, &lt;br /&gt;
                                  ByVal punc As String)&lt;br /&gt;
         Console.WriteLine(aString &amp;amp; punc)&lt;br /&gt;
     End Sub &lt;br /&gt;
 &lt;br /&gt;
 End Module&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 ' Import the module that holds the extension method you want to use, &lt;br /&gt;
 ' and call it. &lt;br /&gt;
 &lt;br /&gt;
 Imports ConsoleApplication2.StringExtensions &lt;br /&gt;
 &lt;br /&gt;
 Module Module1 &lt;br /&gt;
 &lt;br /&gt;
     Sub Main()&lt;br /&gt;
         Dim example = &amp;quot;Hello&amp;quot;&lt;br /&gt;
         example.PrintAndPunctuate(&amp;quot;?&amp;quot;)&lt;br /&gt;
         example.PrintAndPunctuate(&amp;quot;!!!!&amp;quot;)&lt;br /&gt;
     End Sub&lt;br /&gt;
 &lt;br /&gt;
 End Module&lt;br /&gt;
&lt;br /&gt;
Notice that the method is defined with two parameters and called with only one. The first parameter, aString, in the method definition is bound to example, the instance of String that calls the method. The output of the example is as follows:&lt;br /&gt;
 Hello?&lt;br /&gt;
&lt;br /&gt;
 Hello!!!!&lt;/div&gt;</summary>
		<author><name>Macrop</name></author>	</entry>

	</feed>