Skip to content

Commit ae4ffe4

Browse files
dievSean Wheeler
authored andcommitted
Fix example VB code (#2084)
* Fix example VB code This VB code writen in a line is not compilable. `VBFromFilePublic` also requires a space. * Fix example 4 VB code for all versions * Remove the mentioning of version 2.0
1 parent cf184e9 commit ae4ffe4

File tree

6 files changed

+39
-14
lines changed

6 files changed

+39
-14
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Each folder in this repo publishes to [MSDN](https://msdn.microsoft.com/en-us/po
1414
* [/dsc/](https://msdn.microsoft.com/en-us/powershell/dsc/) is for the Desired State Configuration feature
1515
* [/gallery/](https://msdn.microsoft.com/powershell/gallery) is for the [PowerShell Gallery](https://www.powershellgallery.com/)
1616
* [/jea/](https://msdn.microsoft.com/powershell/jea/) is for the Just Enough Administration feature
17-
* [/reference/](https://msdn.microsoft.com/powershell/reference/) is for PowerShell module reference across versions 2.0, 3.0, 4.0, 5.0, 5.1, and 6.0
17+
* [/reference/](https://msdn.microsoft.com/powershell/reference/) is for PowerShell module reference across versions 3.0, 4.0, 5.0, 5.1, and 6.0
1818
* This content will be retrieved by the `Get-Help` cmdlet in the future
1919
* [/scripting/](https://msdn.microsoft.com/en-us/powershell/scripting/) is general PowerShell reference content
2020
* [/wmf](https://msdn.microsoft.com/en-us/powershell/wmf/readme) contains release notes for the Windows Management Framework, the package used to distribute new versions of PowerShell to previous versions of Windows.

reference/3.0/Microsoft.PowerShell.Utility/Add-Type.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,18 +157,18 @@ The wildcard character allows you to get the correct assembly even when you are
157157
The command uses the **PassThru** parameter to generate objects that represent the classes that are added to the session, and it saves the objects in the $accType variable.
158158
### Example 4
159159
```
160-
PS C:\> Add-Type -Path c:\ps-test\Hello.vb
161-
[VBFromFile]::SayHello(", World")
160+
PS C:\> Add-Type -Path "c:\ps-test\Hello.vb"
161+
PS C:\> [VBFromFile]::SayHello(", World")
162162
163163
# From Hello.vb
164164
165165
Public Class VBFromFile
166-
Public Shared Function SayHello(sourceName As String) As String
167-
Dim myValue As String = "Hello"
168-
return myValue + sourceName
169-
End Function
166+
Public Shared Function SayHello(sourceName As String) As String
167+
Dim myValue As String = "Hello"
168+
return myValue + sourceName
169+
End Function
170170
End Class
171-
PS C:\> [VBFromFile]::SayHello(", World")
171+
172172
Hello, World
173173
```
174174

reference/4.0/Microsoft.PowerShell.Utility/Add-Type.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,19 @@ The command uses the **PassThru** parameter to generate objects that represent t
164164

165165
### Example 4
166166
```
167-
PS C:\> Add-Type -Path c:\ps-test\Hello.vb[VBFromFile]::SayHello(", World")
167+
PS C:\> Add-Type -Path "c:\ps-test\Hello.vb"
168+
PS C:\> [VBFromFile]::SayHello(", World")
168169
169170
# From Hello.vb
170171
171-
Public Class VBFromFilePublic Shared Function SayHello(sourceName As String) As StringDim myValue As String = "Hello"return myValue + sourceNameEnd FunctionEnd Class
172-
PS C:\> [VBFromFile]::SayHello(", World")Hello, World
172+
Public Class VBFromFile
173+
Public Shared Function SayHello(sourceName As String) As String
174+
Dim myValue As String = "Hello"
175+
return myValue + sourceName
176+
End Function
177+
End Class
178+
179+
Hello, World
173180
```
174181

175182
This example uses the **Add-Type** cmdlet to add the VBFromFile class that is defined in the Hello.vb file to the current session.

reference/5.0/Microsoft.PowerShell.Utility/Add-Type.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,15 @@ The command uses the *PassThru* parameter to generate objects that represent the
160160
```
161161
PS C:\> Add-Type -Path "c:\ps-test\Hello.vb"
162162
PS C:\> [VBFromFile]::SayHello(", World")
163+
163164
# From Hello.vb
164165
165-
Public Class VBFromFilePublic Shared Function SayHello(sourceName As String) As String Dim myValue As String = "Hello" return myValue + sourceName End Function End Class
166+
Public Class VBFromFile
167+
Public Shared Function SayHello(sourceName As String) As String
168+
Dim myValue As String = "Hello"
169+
return myValue + sourceName
170+
End Function
171+
End Class
166172
167173
Hello, World
168174
```

reference/5.1/Microsoft.PowerShell.Utility/Add-Type.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,15 @@ The command uses the *PassThru* parameter to generate objects that represent the
160160
```
161161
PS C:\> Add-Type -Path "c:\ps-test\Hello.vb"
162162
PS C:\> [VBFromFile]::SayHello(", World")
163+
163164
# From Hello.vb
164165
165-
Public Class VBFromFilePublic Shared Function SayHello(sourceName As String) As String Dim myValue As String = "Hello" return myValue + sourceName End Function End Class
166+
Public Class VBFromFile
167+
Public Shared Function SayHello(sourceName As String) As String
168+
Dim myValue As String = "Hello"
169+
return myValue + sourceName
170+
End Function
171+
End Class
166172
167173
Hello, World
168174
```

reference/6/Microsoft.PowerShell.Utility/Add-Type.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,15 @@ The command uses the *PassThru* parameter to generate objects that represent the
161161
```
162162
PS C:\> Add-Type -Path "c:\ps-test\Hello.vb"
163163
PS C:\> [VBFromFile]::SayHello(", World")
164+
164165
# From Hello.vb
165166
166-
Public Class VBFromFilePublic Shared Function SayHello(sourceName As String) As String Dim myValue As String = "Hello" return myValue + sourceName End Function End Class
167+
Public Class VBFromFile
168+
Public Shared Function SayHello(sourceName As String) As String
169+
Dim myValue As String = "Hello"
170+
return myValue + sourceName
171+
End Function
172+
End Class
167173
168174
Hello, World
169175
```

0 commit comments

Comments
 (0)