Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
Search the Tips
Tip Bank > .NET > VB.NET > Arrays

Arrays - Page 3

41-60 of 97     Previous     Next
ArrayAvg - The average of an array of any numeric type
by Marco Bellinaso
The average of an array of any numeric type Example: Dim arr As Integer() = {3, 7, 8, 2, 0, 9} MessageBox.Show(ArrayAvg(arr))
ArrayFilter - Filtering arrays of any type, with many options
by Marco Bellinaso
Filter the input array. It can work with string arrays or arrays of other type! The input array is modified by removing the elements that do not match the filter options, but the array is not actually re-sized. The filter results will be moved at the beginning of the array, and empty elements ...
ArrayReplace - A Replace routine that works through all the items of the input array
by Marco Bellinaso
A Replace routine that works through all the items of the input array Example: Dim arr As Integer() = {3, 7, 8, 2, 7, 0, 9, 7} ArrayReplace(arr, 7, 100) Dim o As Object For Each o In arr Debug.Write(o & " ") Next Debug.WriteLine("")
FillRandomArray - Fill the input array with random values
by Marco Bellinaso
Fill the input array with random values Example: Dim arr(9) As Integer FillRandomArray(arr, 1, 11) Dim i As Integer For i = 0 To 9 Debug.Write(arr(i) & " ") Next Debug.WriteLine("")
SwapArrayItems - Swap two elements in the input array
by Marco Bellinaso
Swap two elements in the input array Example: Dim arr As Integer() = {3, 7, 8, 2, 0, 9} SwapArrayItems(arr, 1, 4) Dim o As Object For Each o In arr Debug.Write(o & " ") Next Debug.WriteLine("")
TransposeMatrix - Evaluate the transposed matrix
by Marco Bellinaso
Evaluate the transposed matrix A transposed matrix is the array you get when you "rotate" a bi-dimensional array Example Dim arr(,) As Double = {{0.0, 0.1, 0.2}, {1.0, 1.1, 1.2}} Dim i, j As Integer print the original matrix Debug.WriteLine("Original matrix") For i = 0 To arr.
GetRandomArrayItem - Return a random item from an array or collection
by Marco Bellinaso
Return a random item from a mono/bi/tri-dimensional array or collection Example: Dim arr1 As String() = {"this is string 0", "this is string 1", _ "this is string 2", "this is string 3", "this is string 4"} Dim i As Integer For i = 1 To 10 Debug.WriteLine(GetRandomArrayItem(arr1)) Next
Use a Regular Expression to Initialize a String Array (C#)
by A. Russell Jones, Executive Editor
Want to declare and initialize a string array, but tired of typing all those quotes and commas? You can do it with one line of code.
Use a Regular Expression to Initialize a String Array (VB.NET)
by Russell Jones
Want to declare and initialize a string array, but tired of typing all those quotes and commas? You can do it with one line of code.
SemiCRC - A fast CRC-like algorithm
by Ernest Bayazitov
Evaluate the 16-bit Checksum of an array of bytes
RLEUncompress - Uncompress data compressed using RLECompress
by Francesco Balena
Uncompress a block of data compressed with RLECompress Returns TRUE if successful (this version either returns True or raises an error) ADDRESS points to the buffer that holds the compressed data use StrPtr(s) if it's a string, VarPtr(arr(0)) if it's an array BYTES is the size of the ...
ArrayDeleteElement - Deleting an element in any type of array
by Francesco Balena
A generic routine that deletes an element in any type of array. Example: deleting the 2nd element of the array arr ArrayDeleteElement(arr, 1)
ArrayInsertElement - Inserting an element in any type of array
by Francesco Balena
A generic routine that inserts an element in any type of array. Example: inserting an entry of value 5 between the 1st and 2nd entry of the array arr ArrayInsertElement(arr, 1, 5)
ArrayListJoin - Merging two ArrayList objects
by Francesco Balena
A reusable function that merges two ArrayList objects Example: Dim al As New ArrayList() al.Add("Jack") al.Add("Mary") val.Add("Bob") al.Add("Tom") Dim al2 As New ArrayList() al2.Add("Frank") al2.Add("Lee") al2.Add("Nick") al = ArrayListJoin(al, al2)
A For Each loop that iterates in reverse order
by Francesco Balena
The For Each loop always iterates orderly on all the elements of an array or a collection (more precisely, on all the elements of a class that implements the IEnumerable interface). What happens if you need to iterate in reverse order, though? If you have an array or an ArrayList you can always ...
A For Each statement that visits items in random order
by Francesco Balena
At times you may need to process elements of an array, a collection, or a dictionary object in random order, for example when sampling a population or (more often) when writing a game, such as a card game. Here's a class that you can use in a For Each statement to randomly process all the ...
Create zero-elements arrays
by Francesco Balena
The .NET framework lets you create two types of "empty" arrays: unitialized arrays and arrays that are initialized with zero elements. Uninitialized arrays are actually array variables that are set to Nothing, whereas zero-element arrays are non-Nothing variables that point to arrays with zero ...
Store bits and small integers efficiently in a BitVector32
by Francesco Balena
The System.Collections.Specialized.BitVector32 structure can be used to store up to 32 boolean values, or a set of small integers that can take up to 32 consecutive bits. The BitVector32 is similar to the BitArray class, in that it can hold boolean values that take only one bit each, yet it is ...
Store large Boolean arrays in a BitArray object
by Francesco Balena
.NET Boolean values require 4 bytes each, as opposed to the 2 byte taken under previous VB versions. When creating very large Boolean arrays this extra memory impacts negatively on the application's performance. The .NET Framework offers a specialized class, the System.Collection.BitArray ...
Understanding passing arrays by reference
by Francesco Balena
.NET arrays are object types, thus an array variable is actually a pointer to the object where data is actually stored. For this reason, when you pass an array to a procedure the pointer is passed and the called procedure is always able to modify the elements of the array, regardless of whether ...
41-60 of 97     Previous     Next
Sitemap