Monday, August 29, 2011

[Research] Visual Basic - String Manipulation

StrComp-
Overloads: 0
Parameters: String1:String, String2:String, Compare:CompareMethod
Return type: Integer
Exceptions: ArgumentException
Details:
StrComp compares String2 to String1, based on the (optional) Compare parameter. If String1 comes BEFORE String2 (in order), the return will be a -1, if they are the same, it will return a 0, if it comes AFTER String 2, it will return a -1.


StrConv-
Overloads: 11
Parameters: str:String, Conversion:VbStrConv, LocaleID:Integer
Return type: String
Exceptions: ArgumentException
Details:
StrConv converts str using the VbStrConv function. for example. VbStrConv.LowerCase will return a string with all lower case letters.


StrReverse-
Overloads: 0
Parameters: Expression:String
Return type: String
Exceptions: N/A
Details:
StrReverse just reverses the order of the entire string.



StrTrim-
Overloads: 0
Parameters: str:String
Return type: String
Exceptions: N/A
Details:
StrTrim removes all leading and trailing spaces. ie, no spaces at the start, or at the end of the string.


Strings.Join-
Overloads: 0
Parameters: SourceArray:String, Delimiter:String
Return type: String
Exceptions: ArgumentException
Details:
Strings.Join will get all the values, or the specific value, from an array or string, and add them together. The Delimiter will add a certain characters (default a space) between each item that is joined. If an array has the numbers 1 to 10, and the delimiter was a colon ":", the output would be 1:2:3:4:5 etc.

Strings.Replace-
Overloads: 0
Parameters: Expression:String, Find:String, Replacement:String, Start:Integer, Count:Integer, Compare:CompareMethod
Return: String
Exceptions: ArgumentException
Details: This function replaces certain strings or characters with others, within a source string. Count counts how many have been replaced. Start is the integer location of the start of the string to search to replace.

Monday, August 22, 2011

[Research] Visual Basic - Try/Catch Block

In Exception Handling, the Try/Catch block is a large nested If loop that checks for Exceptions, and if they are found, how to deal with them.

[Research] Visual Basic - Exception Heirarchy

There are two types of Exceptions. The first are exceptions generated while the program is being run, and the other is from bad syntax in the code writing or the coding environment. This basically means that Exceptions are either caused from the program creating undesirable inputs(eg accessing outside of an existing array location), or the programmer's misuse of syntax or improper coding language, causing an error before the program is even compiled.

[Research] Visual Basic - Exception Classes

The purpose of the Exception Class is to throw Exceptions (with specific error message) so that the user can understand what is going in. It also prevents code from executing if it is not suitable or otherwise unusable. It inherits directly from System.Object class.

The Exception class has 4 constructors, Exception(), Exception(String), Exception(SerializationInfo, StreamingContext), and Exception(String, Exception).

[Research] Visual Basic - Exceptions

An exception is an event that happens when a program is told to perform an operation with unsuitable inputs. Eg, Overload Exceptions, when you try to place a number greater than the maximum in an integer, it overflows. It is, basically, an error that the program cannot recover from by itself and continue to run regardless.

Sunday, August 14, 2011

[Code] Visual Basic - Stripping Strings

In this example, I will show you how to strip a substring from a source string. The string I will be using is "Leftstring : Rightstring". In this case we will be getting Rightstring.


First, (optionally), you get the full string length using Len. This returns an integer.


Len(myString)


Then, you would use InStr to find the location of the colon. This ALSO returns an integer.


InStr(1, myString, ":")


Now we will run the Mid function with simple maths to return the RightString. We use colonPosition+2 to return the string AFTER the space, not including it.


Mid(myStr, (colonPosition+2), Len(myString))


Similarly, to return Leftstring, we would just use Mid slightly differently.


Mid(myStr, 1, (colonPosition-2))

[Research] Visual Basic Functions - HashTables

A HashTable is similar to an Array. It is a table consisting of 2 columns, Key and Value. Every item you put in to the HashTable will have a unique Key and a Value associated with it. Each Key/Value is an 'element', and are stored as DictionaryEntry object types.

To read more about HashTables, check out the MSDN article here.

[Research] Sequence Diagrams - What are they?

Sequence digrams are a visual representation of a program. It includes the calls, functions, what they return, and the flow of the entire program so you can see when functions are called, and how they interact. This is an example of what a Sequence Diagram, or a UML diagram, looks like.

StarUML is a freeware program that is easy to use and creates simple and clean UML (Sequence) Diagrams.
You can download it here. (StarUML 5.0 Winx32)

[Research] Visual Basic Functions - Mid


The Mid function has 2 required and one optional input. It returns characters(as a String) from a string, starting at point x, until point y.

Mid(str, Start, Length).

str is the string to be searched, Start is the integer number of the first character to return, and Length is an optional length parameter. If not input, it will return the string from Start to the end of the string.

[Research] Visual Basic Functions - InStr

Visual Basic's InStr function has 3 required and one optional input parameter. It is declared like so;

InStr(startPosition, string1, string2, compare).

These are the starting position to search from, the string to search inside of, and the string you want to search for. The last parameter is an optional one, it specifies whether the string is searched for using a binary or text style. It returns an integer, displaying the location of the searched string inside the source string.

[Research] Visual Basic Functions - Len

The len function in Visual Basic has the input parameters as such; len(inputString), and it returns an integer, the length of the string you specified in the input parameter.

[Research] Windows Media Player - Filetype Compatibility

A handful of compatible Filetypse in Windows Media Player are MP3, WAVE, MP4, MPEG, and WMA.

[Research] Windows Media Player - Pause

In Visual Basic, the Windows Media Play FastReverse function sets the play speed to -5x, though it doesn't work with almost any, if any media filetypes. Has better support with video.

[Research] Windows Media Player - FastForward

Windows Media Player's FastForward function sets the play speed to 5x. This can be set back to 1x by pressing the play button.

[Research] Windows Media Player - Pause

The Windows Media Player object in Visual Basic simply pauses playback of the media file, that is all.

[Research] Windows Media Player - Stop

The Stop function of the Windows Media Player object in Visual Basic stops the current loaded media file and returns it to the starting point, but does not change or unload the media file.

[Research] Windows Media Player - Play

The Play function of the WMP object in Visual Basic has no input parameters, but it sets the currently loaded media file to play at regular speed.