background preloader

SQL Item Selector

Facebook Twitter

How to: Search Within a String (Visual Basic) This example calls the IndexOf method on a String object to report the index of the first occurrence of a substring.

How to: Search Within a String (Visual Basic)

Dim SearchWithinThis As String = "ABCDEFGHIJKLMNOP" Dim SearchForThis As String = "DEF" Dim FirstCharacter As Integer = SearchWithinThis.IndexOf(SearchForThis) The IndexOf method reports the location of the first character of the first occurrence of the substring. The index is 0-based, which means the first character of a string has an index of 0. If IndexOf does not find the substring, it returns -1. The IndexOf method is case-sensitive and uses the current culture. For optimal error control, you might want to enclose the string search in the Try block of a Try...Catch...Finally Statement (Visual Basic) construction. Reference Other Resources. Vb.net - Count specific character occurrences in string. How many times a string occurs in another string (textbox) VB.NET. Count distinct characters in a String. Passing any control as parameter in vb.net function.

Visual Basic 2008/2010 Tutorials: Function to count how many times a string occurs. How to: Add, Delete, and Retrieve Items of a Collection. Collective confusion: Using collections in .NET. How to: Pass Objects to Procedures. Updated: October 2008 Visual Basic allows you to pass objects as arguments to procedures in the same way that you pass other types of arguments.

How to: Pass Objects to Procedures

The following procedures demonstrate how. To pass a new instance of a form to a procedure Create a Windows Forms application. Add a button, Button1, to Form1.Copy the following code into Form1.vb: Private Sub Button1_Click(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles Button1.Click Dim newForm As New Form1 newForm.Show() CenterForm(newForm) End Sub Sub CenterForm(ByVal TheForm As Form) ' Centers the form on the screen when you click the button. To pass an object reference to a procedure on another form. How to create an array of VB.net objects from a VB .net class. Class Hierarchy Design Considerations for Extensibility. Even well-designed class hierarchies need to evolve over time.

Class Hierarchy Design Considerations for Extensibility

The early choices you make when designing a class hierarchy can simplify your work later. The following list contains suggestions for making your class hierarchies easier to extend: Class hierarchies are defined from the general to the specific. Define classes to be as general as possible at each level of an inheritance hierarchy. Derived classes can inherit, reuse, and extend methods from base classes. Memory - How to dispose a class in .net. How to: Create Derived Classes. The Inherits statement causes a class to inherit all the non-private members of the specified class.

How to: Create Derived Classes

To inherit from another class Add an Inherits statement with the name of a class you want to use as a base class as the first statement in your derived class. The Inherits statement must be the first non-comment statement after the class statement. The following example defines two classes. The first class is a base class that has two methods. Class Class1 Sub Method1() MsgBox("This is a method in the base class. ") When you run the procedure TestInheritance, you see the following messages: VB.NET School - Instantiating a Class - Lesson #4 - Page 2. Visual Basic 2008 9.0 .NET Examples - Arrays as Arguments - Procedures and Functions. Char Data Type (Visual Basic) Holds unsigned 16-bit (2-byte) code points ranging in value from 0 through 65535.

Char Data Type (Visual Basic)

Each code point, or character code, represents a single Unicode character. Use the Char data type when you need to hold only a single character and do not need the overhead of String. In some cases you can use Char(), an array of Char elements, to hold multiple characters. The default value of Char is the character with a code point of 0. Unicode Characters The first 128 code points (0–127) of Unicode correspond to the letters and symbols on a standard U.S. keyboard.

You can use methods like IsDigit and IsPunctuation on a Char variable to determine its Unicode classification. Type Conversions Visual Basic does not convert directly between Char and the numeric types. If the type checking switch (Option Strict Statement) is on, you must append the literal type character to a single-character string literal to identify it as the Char data type. Programming Tips.