Skip to content

Commit

Permalink
Fix vb array size (#1480)
Browse files Browse the repository at this point in the history
* Fix vb array size

* More fixes

* More fixes

* More fixes

* More fixes

* Update snippets/visualbasic/VS_Snippets_CFX/s_uechannels/vb/clientsnippets.vb

Co-Authored-By: Ron Petrusha <[email protected]>

* Update clientsnippets.vb
  • Loading branch information
Youssef1313 authored and Ron Petrusha committed Sep 25, 2019
1 parent 68887cb commit 57c4233
Show file tree
Hide file tree
Showing 47 changed files with 64 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Module Module1
Private Sub AddForeignConstraint( _
ByVal dataSet As DataSet, ByVal table As DataTable)
Try
Dim parentColumns(2) As DataColumn
Dim childColumns(2) As DataColumn
Dim parentColumns(1) As DataColumn
Dim childColumns(1) As DataColumn
' Get the tables from the DataSet.
Dim customersTable As DataTable = _
dataSet.Tables("Customers")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Private Sub DemonstrateMerge()
Type.GetType("System.Int32"), "")

' Create DataColumn array to set primary key.
Dim keyColumn(1) As DataColumn
Dim keyColumn(0) As DataColumn
Dim row As DataRow

' Create variable for temporary DataSet.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Public Class Form1
Dim itemColumn As New DataColumn("Item", Type.GetType("System.Int32"))

' DataColumn array to set primary key.
Dim keyColumn(1) As DataColumn
Dim keyColumn(0) As DataColumn
Dim row As DataRow

' Create variable for temporary DataSet.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Private Sub DemonstrateMergeMissingSchema()
Type.GetType("System.Int32"))

' DataColumn array to set primary key.
Dim keyColumn(1) As DataColumn
Dim keyColumn(0) As DataColumn
Dim row As DataRow

' Create variable for temporary DataSet.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Private Sub DemonstrateMergeTable()
table.Columns.Add(c2)

' DataColumn array to set primary key.
Dim keyCol(1) As DataColumn
Dim keyCol(0) As DataColumn

' Set primary key column.
keyCol(0) = c1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Private Sub DemonstrateMergeTableAddSchema()
table.Columns.Add(itemColumn)

' DataColumn array to set primary key.
Dim keyCol(1) As DataColumn
Dim keyCol(0) As DataColumn

' Set primary key column.
keyCol(0) = idColumn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Class Class1
categories.Columns.Add(column)

' Set the primary key on CategoryID.
Dim pKey(1) As DataColumn
Dim pKey(0) As DataColumn
pKey(0) = categories.Columns("CategoryID")
categories.PrimaryKey = pKey

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Module Client
lineItem2.quantity = 890
lineItem2.unitCost = 45.89F

Dim lineItems(2) As PurchaseOrderLineItem
Dim lineItems(1) As PurchaseOrderLineItem
lineItems(0) = lineItem1
lineItems(1) = lineItem2
po.orderLineItems = lineItems
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ Public Class clientSnippets

Public Shared Sub Snippet11()
' <Snippet11>
Dim binding As CustomBinding = New CustomBinding()
Dim binding As New CustomBinding()
binding.Elements.Add(New HttpTransportBindingElement())
Dim paramCollection As BindingParameterCollection = New BindingParameterCollection()
Dim paramCollection As New BindingParameterCollection()

binding.CanBuildChannelFactory(Of IRequestChannel)(paramCollection)
' </Snippet11>
End Sub

Public Shared Sub Snippet12()
' <Snippet12>
Dim binding As CustomBinding = New CustomBinding()
Binding.Elements.Add(New HttpTransportBindingElement())
Dim bindingParameters(2) As Object
Dim binding As New CustomBinding()
binding.Elements.Add(New HttpTransportBindingElement())
Dim bindingParameters(1) As Object

binding.CanBuildChannelFactory(Of IRequestChannel)(bindingParameters)
' </Snippet12>
Expand All @@ -29,11 +29,11 @@ Public Class clientSnippets
' <Snippet3>
Dim binding As CustomBinding = New CustomBinding()
binding.Elements.Add(New HttpTransportBindingElement())
Dim bindingParams(2) As Object
Dim bindingParams(1) As Object

Dim factory As IChannelFactory(Of IRequestChannel) = binding.BuildChannelFactory(Of IRequestChannel)(bindingParams)
factory.Open()
Dim address As EndpointAddress = New EndpointAddress("http://localhost/channelApp/service")
Dim address As New EndpointAddress("http://localhost/channelApp/service")
Dim channel As IRequestChannel = factory.CreateChannel(address)
channel.Open()
Dim request As Message = Message.CreateMessage(MessageVersion.Default, "hello")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Namespace UE.Samples.Channel
' <Snippet5>
Dim binding As CustomBinding = New CustomBinding()
binding.Elements.Add(New HttpTransportBindingElement())
Dim bindingParameters(2) As Object
Dim bindingParameters(1) As Object

Dim listener As IChannelListener(Of IReplyChannel)
listener = binding.BuildChannelListener(Of IReplyChannel)(bindingParameters)
Expand Down Expand Up @@ -69,7 +69,7 @@ Namespace UE.Samples.Channel
' <Snippet6>
Dim binding As CustomBinding = New CustomBinding()
binding.Elements.Add(New HttpTransportBindingElement())
Dim bindingParameters(2) As Object
Dim bindingParameters(1) As Object
Dim listener As IChannelListener(Of IReplyChannel)
listener = binding.BuildChannelListener(Of IReplyChannel)(New Uri("http://localhost/channelApp"), bindingParameters)
' </Snippet6>
Expand All @@ -89,7 +89,7 @@ Namespace UE.Samples.Channel
' <Snippet8>
Dim binding As CustomBinding = New CustomBinding()
binding.Elements.Add(New HttpTransportBindingElement())
Dim bindingParameters(2) As Object
Dim bindingParameters(1) As Object
Dim listener As IChannelListener(Of IReplyChannel)
listener = binding.BuildChannelListener(Of IReplyChannel)(New Uri("http://localhost/channelApp"), "http://localhost/channelApp/service", bindingParameters)
' </Snippet8>
Expand All @@ -109,7 +109,7 @@ Namespace UE.Samples.Channel
' <Snippet10>
Dim binding As CustomBinding = New CustomBinding()
binding.Elements.Add(New HttpTransportBindingElement())
Dim bindingParameters(2) As Object
Dim bindingParameters(1) As Object
Dim listener As IChannelListener(Of IReplyChannel)
listener = binding.BuildChannelListener(Of IReplyChannel)(New Uri("http://localhost/channelApp"), "http://localhost/channelApp/service", ListenUriMode.Explicit, bindingParameters)
'</Snippet10>
Expand All @@ -129,7 +129,7 @@ Namespace UE.Samples.Channel
' <Snippet14>
Dim binding As CustomBinding = New CustomBinding()
binding.Elements.Add(New HttpTransportBindingElement())
Dim bindingParameters(2) As Object
Dim bindingParameters(1) As Object

binding.CanBuildChannelFactory(Of IReplyChannel)(bindingParameters)
'</Snippet14>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Class Snippets
lineItem2.quantity = 890
lineItem2.unitCost = 45.89F

Dim lineItems(2) As PurchaseOrderLineItem
Dim lineItems(1) As PurchaseOrderLineItem
lineItems(0) = lineItem1
lineItems(1) = lineItem2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ Namespace Microsoft.ServiceModel.Samples.Federation
'/ <returns>Proof Token</returns>
Protected Shared Function CreateProofToken(ByVal keySize As Integer) As BinarySecretSecurityToken
' Create an array to store the key bytes.
Dim key(keySize / 8) As Byte
Dim key(keySize / 8 - 1) As Byte
' Create some random bytes.
Dim random As New RNGCryptoServiceProvider()
random.GetNonZeroBytes(key)
Expand Down Expand Up @@ -763,7 +763,7 @@ Namespace Microsoft.ServiceModel.Samples.Federation
Dim nBytes As Integer = xr.ReadContentAsBase64(temp, 0, temp.Length)

' Allocate a new array of the correct size to hold the provided entropy.
Dim entropy(nBytes) As Byte
Dim entropy(nBytes - 1) As Byte

' Copy the entropy from the temporary array into the new array.
Dim i As Integer
Expand Down Expand Up @@ -1029,9 +1029,9 @@ Namespace Microsoft.ServiceModel.Samples.Federation
Public Shared Function ComputeCombinedKey(ByVal requestorEntropy() As Byte, ByVal issuerEntropy() As Byte, ByVal keySize As Integer) As Byte()
Dim kha As KeyedHashAlgorithm = New HMACSHA1(requestorEntropy, True)

Dim key(keySize / 8) As Byte ' Final key
Dim key(keySize / 8 - 1) As Byte ' Final key
Dim a As Byte() = issuerEntropy ' A(0)
Dim b(kha.HashSize / 8 + a.Length) As Byte ' Buffer for A(i) + seed
Dim b(kha.HashSize / 8 + a.Length - 1) As Byte ' Buffer for A(i) + seed
Dim i As Integer

While i < key.Length
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1787,7 +1787,7 @@ Namespace WF_Snippets

Public Function SerializeToolboxItem(ByVal toolboxItem As ToolboxItem) As Object Implements IToolboxService.SerializeToolboxItem
Dim components As IComponent() = toolboxItem.CreateComponents()
Dim activities(components.Length) As Activity
Dim activities(components.Length - 1) As Activity
components.CopyTo(activities, 0)

Return CompositeActivityDesigner.SerializeActivitiesToDataObject(Me.provider, activities)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,7 @@ Namespace WF_Snippets
' file opened for shared reads but no writes by anyone
fileStream = New FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read)
fileStream.Seek(0, SeekOrigin.Begin)
Dim workflowBytes((CType(fileStream.Length, Integer))) As Byte
Dim workflowBytes(CInt(fileStream.Length - 1)) As Byte

' get the serialized form
fileStream.Read(workflowBytes, 0, workflowBytes.Length)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Module Test
' Loads the content of a file to a byte array.
Function loadFile(filename As String) As Byte()
Dim fs As New FileStream(filename, FileMode.Open)
Dim buffer(CInt(fs.Length)) As Byte
Dim buffer(CInt(fs.Length - 1)) As Byte
fs.Read(buffer, 0, buffer.Length)
fs.Close()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ Public Class ArrayTypeMisMatchConst

Shared Sub Main()
Try
Dim myStringArray(2) As String
Dim myStringArray(1) As String
myStringArray.SetValue("Jones", 0)
myStringArray.SetValue("John", 1)
Dim myIntArray(2) As Integer
Dim myIntArray(1) As Integer
Dim myArrayType As New ArrayTypeMisMatchConst()
myArrayType.CopyArray(myStringArray, myIntArray)
Catch e As ArrayTypeMismatchException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ Public Class ArrayTypeMisMatchConst

Shared Sub Main()
Try
Dim myStringArray(2) As String
Dim myStringArray(1) As String
myStringArray.SetValue("Jones", 0)
myStringArray.SetValue("John", 1)
Dim myIntArray(2) As Integer
Dim myIntArray(1) As Integer
Dim myArrayType As New ArrayTypeMisMatchConst()
myArrayType.CopyArray(myStringArray, myIntArray)
Catch e As ArrayTypeMismatchException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ Public Class ArrayTypeMisMatchConst

Shared Sub Main()
Try
Dim myStringArray(2) As String
Dim myStringArray(1) As String
myStringArray.SetValue("Jones", 0)
myStringArray.SetValue("John", 1)
Dim myIntArray(2) As Integer
Dim myIntArray(1) As Integer
Dim myArrayType As New ArrayTypeMisMatchConst()
myArrayType.CopyArray(myStringArray, myIntArray)
Catch e As ArrayTypeMismatchException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Public Class AssemblyName_CodeBase
myAssemblyName.Flags = AssemblyNameFlags.PublicKey
' Get the whole contents of the 'PublicKey.snk' into a byte array.
Dim publicKeyStream As FileStream = File.Open("PublicKey.snk", FileMode.Open)
Dim publicKey(publicKeyStream.Length) As Byte
Dim publicKey(publicKeyStream.Length - 1) As Byte
publicKeyStream.Read(publicKey, 0, CInt(publicKeyStream.Length))
' Provide the assembly with a public key.
myAssemblyName.SetPublicKey(publicKey)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Class MainWindow
End Sub

Public Async Function CopyFilesAsync(Source As StreamReader, Destination As StreamWriter) As Task
Dim buffer(4096) As Char
Dim buffer(4095) As Char
Dim numRead As Integer

numRead = Await Source.ReadAsync(buffer, 0, buffer.Length)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Class CertInfo
Friend Shared Function ReadFile(ByVal fileName As String) As Byte()
Dim f As New FileStream(fileName, FileMode.Open, FileAccess.Read)
Dim size As Integer = Fix(f.Length)
Dim data(size) As Byte
Dim data(size - 1) As Byte
size = f.Read(data, 0, size)
f.Close()
Return data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Public Class Class1
'<Snippet6>
' Copies the contents of the collection beginning at index 0 to the specified CodeStatement array.
' 'statements' is a CodeStatement array.
Dim statementArray(collection.Count) As CodeStatement
Dim statementArray(collection.Count - 1) As CodeStatement
collection.CopyTo(statementArray, 0)
'</Snippet6>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Module TripleDESPSample
CryptoStreamMode.Read)

' Create buffer to hold the decrypted data.
Dim fromEncrypt(Data.Length) As Byte
Dim fromEncrypt(Data.Length - 1) As Byte

' Read the decrypted data out of the crypto stream
' and place it into the temporary buffer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Module DESSample
CryptoStreamMode.Read)

' Create buffer to hold the decrypted data.
Dim fromEncrypt(Data.Length) As Byte
Dim fromEncrypt(Data.Length - 1) As Byte

' Read the decrypted data out of the crypto stream
' and place it into the temporary buffer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Module DESPSample
CryptoStreamMode.Read)

' Create buffer to hold the decrypted data.
Dim fromEncrypt(Data.Length) As Byte
Dim fromEncrypt(Data.Length - 1) As Byte

' Read the decrypted data out of the crypto stream
' and place it into the temporary buffer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Module DESCSPSample
CryptoStreamMode.Read)

' Create buffer to hold the decrypted data.
Dim fromEncrypt(Data.Length) As Byte
Dim fromEncrypt(Data.Length - 1) As Byte

' Read the decrypted data out of the crypto stream
' and place it into the temporary buffer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Module RC2Sample
CryptoStreamMode.Read)

' Create buffer to hold the decrypted data.
Dim fromEncrypt(Data.Length) As Byte
Dim fromEncrypt(Data.Length - 1) As Byte

' Read the decrypted data out of the crypto stream
' and place it into the temporary buffer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Module RC2PSample
CryptoStreamMode.Read)

' Create buffer to hold the decrypted data.
Dim fromEncrypt(Data.Length) As Byte
Dim fromEncrypt(Data.Length - 1) As Byte

' Read the decrypted data out of the crypto stream
' and place it into the temporary buffer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Module MyMainModule
Dim msDecrypt As New MemoryStream(encryptedBytes)
Dim csDecrypt As New CryptoStream(msDecrypt, rc2CSP.CreateDecryptor(rc2CSP.Key, rc2CSP.IV), CryptoStreamMode.Read)

Dim unencryptedBytes(originalBytes.Length) As Byte
Dim unencryptedBytes(originalBytes.Length - 1) As Byte

'Read the data out of the crypto stream.
csDecrypt.Read(unencryptedBytes, 0, unencryptedBytes.Length)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ Public Module MemoryProtectionSample
End If


Dim inBuffer(Length) As Byte
Dim inBuffer(Length - 1) As Byte
Dim outBuffer() As Byte

' Read the encrypted data from a stream.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Public Class Test

'Open the stream and read it back.
fs = fi.Open(FileMode.Open)
Dim b(1024) As Byte
Dim b(1023) As Byte
Dim temp As UTF8Encoding = New UTF8Encoding(True)
Do While fs.Read(b, 0, b.Length) > 0
Console.WriteLine(temp.GetString(b))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Public Class Test

'Open the stream and read it back.
fs = fi.Open(FileMode.Open, FileAccess.Read)
Dim b(1024) As byte
Dim b(1023) As byte
Dim temp As UTF8Encoding = New UTF8Encoding(true)

Do While fs.Read(b,0,b.Length) > 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Public Class Test

'Open the stream and read it back.
fs = fi.OpenRead()
Dim b(1024) As Byte
Dim b(1023) As Byte
Dim temp As UTF8Encoding = New UTF8Encoding(True)

Do While fs.Read(b, 0, b.Length) > 0
Expand Down
Loading

0 comments on commit 57c4233

Please sign in to comment.