Vb.net String

Embed Size (px)

Citation preview

  • 7/31/2019 Vb.net String

    1/5

    VB.NET String

    ArrayClassCollectionsFileStringConsoleDataEnumInterfaceLambdaLoopNumberProcess

    PropertyRegexSortStringBuilderStructureSubTimeWindows

    Strings store collections of characters. There are many different functions you can use on Strings

    in the VB.NET programming language. This selection of content details the String-based

    functions in this language.

    Example

    To start, this program demonstrates several concepts: how to declare and initialize a String; how

    to use a String literal such as "dot"; and how to concatenate strings with the plus operator and

    with the String.Concat method.

    Program that uses String [VB.NET]

    Module Module1

    Sub Main()

    Dim value As String = "dot"

    value = value + "net"

    Dim result As String = String.Concat(value, "perls")

    Console.WriteLine(result)

    End Sub

    End Module

    Output

    dotnetperls

    http://www.dotnetperls.com/array-vbnethttp://www.dotnetperls.com/class-vbnethttp://www.dotnetperls.com/class-vbnethttp://www.dotnetperls.com/collections-vbnethttp://www.dotnetperls.com/collections-vbnethttp://www.dotnetperls.com/file-vbnethttp://www.dotnetperls.com/file-vbnethttp://www.dotnetperls.com/file-vbnethttp://www.dotnetperls.com/console-write-vbnethttp://www.dotnetperls.com/console-write-vbnethttp://www.dotnetperls.com/datatable-vbnethttp://www.dotnetperls.com/datatable-vbnethttp://www.dotnetperls.com/enum-vbnethttp://www.dotnetperls.com/enum-vbnethttp://www.dotnetperls.com/interface-vbnethttp://www.dotnetperls.com/interface-vbnethttp://www.dotnetperls.com/lambda-vbnethttp://www.dotnetperls.com/lambda-vbnethttp://www.dotnetperls.com/for-vbnethttp://www.dotnetperls.com/for-vbnethttp://www.dotnetperls.com/number-vbnethttp://www.dotnetperls.com/number-vbnethttp://www.dotnetperls.com/process-start-vbnethttp://www.dotnetperls.com/process-start-vbnethttp://www.dotnetperls.com/process-start-vbnethttp://www.dotnetperls.com/property-vbnethttp://www.dotnetperls.com/regex-match-vbnethttp://www.dotnetperls.com/regex-match-vbnethttp://www.dotnetperls.com/sort-vbnethttp://www.dotnetperls.com/sort-vbnethttp://www.dotnetperls.com/stringbuilder-vbnethttp://www.dotnetperls.com/stringbuilder-vbnethttp://www.dotnetperls.com/structurehttp://www.dotnetperls.com/structurehttp://www.dotnetperls.com/subhttp://www.dotnetperls.com/subhttp://www.dotnetperls.com/datetime-vbnethttp://www.dotnetperls.com/datetime-vbnethttp://www.dotnetperls.com/windows-vbnethttp://www.dotnetperls.com/windows-vbnethttp://www.dotnetperls.com/windows-vbnethttp://www.dotnetperls.com/vbhttp://www.dotnetperls.com/vbhttp://www.dotnetperls.com/vbhttp://www.dotnetperls.com/vbhttp://www.dotnetperls.com/windows-vbnethttp://www.dotnetperls.com/datetime-vbnethttp://www.dotnetperls.com/subhttp://www.dotnetperls.com/structurehttp://www.dotnetperls.com/stringbuilder-vbnethttp://www.dotnetperls.com/sort-vbnethttp://www.dotnetperls.com/regex-match-vbnethttp://www.dotnetperls.com/property-vbnethttp://www.dotnetperls.com/process-start-vbnethttp://www.dotnetperls.com/number-vbnethttp://www.dotnetperls.com/for-vbnethttp://www.dotnetperls.com/lambda-vbnethttp://www.dotnetperls.com/interface-vbnethttp://www.dotnetperls.com/enum-vbnethttp://www.dotnetperls.com/datatable-vbnethttp://www.dotnetperls.com/console-write-vbnethttp://www.dotnetperls.com/file-vbnethttp://www.dotnetperls.com/collections-vbnethttp://www.dotnetperls.com/class-vbnethttp://www.dotnetperls.com/array-vbnet
  • 7/31/2019 Vb.net String

    2/5

    Core functions. These functions and subroutines are some of the most useful and widely used in

    the VB.NET language. Having an understanding of them is important for beginning VB.NET

    developers. This knowledge will carry over to other .NET languages as well.

    EqualsFormatInsertLengthRemoveReplaceString ConstructorSubstringToCharArray

    ToString

    Manipulate strings. These examples manipulate Strings and arrays of Strings in various ways.

    Strings are often stored in arrays.

    String ArrayReverseString LoopMid

    Upper and lower

    The .NET Framework provides us with many different ways to change the cases of characters in

    Strings. With the VB.NET language, we can use these functions or design our own, custom

    functions.

    ToLowerToUpperUppercase First Letter: StringToTitleCase Function

    Split and Join

    Some of the more popular String functions in the VB.NET language include the Split and Join

    methods. We provide examples in the following tutorials.

    SplitJoin

    Search

    http://www.dotnetperls.com/string-equals-vbnethttp://www.dotnetperls.com/string-format-vbnethttp://www.dotnetperls.com/string-format-vbnethttp://www.dotnetperls.com/insert-vbnethttp://www.dotnetperls.com/insert-vbnethttp://www.dotnetperls.com/string-length-vbnethttp://www.dotnetperls.com/string-length-vbnethttp://www.dotnetperls.com/remove-vbnethttp://www.dotnetperls.com/remove-vbnethttp://www.dotnetperls.com/replace-vbnethttp://www.dotnetperls.com/replace-vbnethttp://www.dotnetperls.com/string-constructor-vbnethttp://www.dotnetperls.com/string-constructor-vbnethttp://www.dotnetperls.com/substring-vbnethttp://www.dotnetperls.com/substring-vbnethttp://www.dotnetperls.com/tochararray-vbnethttp://www.dotnetperls.com/tochararray-vbnethttp://www.dotnetperls.com/tochararray-vbnethttp://www.dotnetperls.com/tostring-vbnethttp://www.dotnetperls.com/string-array-vbnethttp://www.dotnetperls.com/reverse-string-vbnethttp://www.dotnetperls.com/reverse-string-vbnethttp://www.dotnetperls.com/loop-string-vbnethttp://www.dotnetperls.com/loop-string-vbnethttp://www.dotnetperls.com/midhttp://www.dotnetperls.com/midhttp://www.dotnetperls.com/midhttp://www.dotnetperls.com/tolower-vbnethttp://www.dotnetperls.com/toupper-vbnethttp://www.dotnetperls.com/toupper-vbnethttp://www.dotnetperls.com/uppercase-first-letter-vbnethttp://www.dotnetperls.com/uppercase-first-letter-vbnethttp://www.dotnetperls.com/totitlecase-vbnethttp://www.dotnetperls.com/totitlecase-vbnethttp://www.dotnetperls.com/totitlecase-vbnethttp://www.dotnetperls.com/split-vbnethttp://www.dotnetperls.com/join-vbnethttp://www.dotnetperls.com/join-vbnethttp://www.dotnetperls.com/join-vbnethttp://www.dotnetperls.com/vbhttp://www.dotnetperls.com/vbhttp://www.dotnetperls.com/vbhttp://www.dotnetperls.com/vbhttp://www.dotnetperls.com/join-vbnethttp://www.dotnetperls.com/split-vbnethttp://www.dotnetperls.com/totitlecase-vbnethttp://www.dotnetperls.com/uppercase-first-letter-vbnethttp://www.dotnetperls.com/toupper-vbnethttp://www.dotnetperls.com/tolower-vbnethttp://www.dotnetperls.com/midhttp://www.dotnetperls.com/loop-string-vbnethttp://www.dotnetperls.com/reverse-string-vbnethttp://www.dotnetperls.com/string-array-vbnethttp://www.dotnetperls.com/tostring-vbnethttp://www.dotnetperls.com/tochararray-vbnethttp://www.dotnetperls.com/substring-vbnethttp://www.dotnetperls.com/string-constructor-vbnethttp://www.dotnetperls.com/replace-vbnethttp://www.dotnetperls.com/remove-vbnethttp://www.dotnetperls.com/string-length-vbnethttp://www.dotnetperls.com/insert-vbnethttp://www.dotnetperls.com/string-format-vbnethttp://www.dotnetperls.com/string-equals-vbnet
  • 7/31/2019 Vb.net String

    3/5

    If you need to search your String for a character pattern or a single character, these IndexOf and

    LastIndexOf functions are ideal.

    ContainsIndexOfIndexOfAnyLastIndexOfLastIndexOfAny

    Whitespace

    Some functions on the string type typically are used to handle whitespace characters; these

    functions include the Trim function and its variants TrimStart and TrimEnd.

    TrimTrimEndTrimStartNewLineLSet and RSetLTrim and RTrim

    Ends and starts

    Sometimes you need to see if one String ends with another String, or if one String starts with

    another String. To our relief, we can use the EndsWith and StartsWith functions.

    EndsWithStartsWith

    ROT13

    http://www.dotnetperls.com/contains-vbnethttp://www.dotnetperls.com/indexof-vbnethttp://www.dotnetperls.com/indexof-vbnethttp://www.dotnetperls.com/indexofany-vbnethttp://www.dotnetperls.com/indexofany-vbnethttp://www.dotnetperls.com/lastindexof-vbnethttp://www.dotnetperls.com/lastindexof-vbnethttp://www.dotnetperls.com/lastindexofany-vbnethttp://www.dotnetperls.com/lastindexofany-vbnethttp://www.dotnetperls.com/lastindexofany-vbnethttp://www.dotnetperls.com/trim-vbnethttp://www.dotnetperls.com/trimend-vbnethttp://www.dotnetperls.com/trimend-vbnethttp://www.dotnetperls.com/trimstart-vbnethttp://www.dotnetperls.com/trimstart-vbnethttp://www.dotnetperls.com/newline-vbnethttp://www.dotnetperls.com/newline-vbnethttp://www.dotnetperls.com/lset-rsethttp://www.dotnetperls.com/lset-rsethttp://www.dotnetperls.com/ltrimhttp://www.dotnetperls.com/ltrimhttp://www.dotnetperls.com/ltrimhttp://www.dotnetperls.com/endswith-vbnethttp://www.dotnetperls.com/startswith-vbnethttp://www.dotnetperls.com/startswith-vbnethttp://www.dotnetperls.com/startswith-vbnethttp://www.dotnetperls.com/vbhttp://www.dotnetperls.com/vbhttp://www.dotnetperls.com/vbhttp://www.dotnetperls.com/vbhttp://www.dotnetperls.com/vbhttp://www.dotnetperls.com/vbhttp://www.dotnetperls.com/vbhttp://www.dotnetperls.com/vbhttp://www.dotnetperls.com/vbhttp://www.dotnetperls.com/startswith-vbnethttp://www.dotnetperls.com/endswith-vbnethttp://www.dotnetperls.com/ltrimhttp://www.dotnetperls.com/lset-rsethttp://www.dotnetperls.com/newline-vbnethttp://www.dotnetperls.com/trimstart-vbnethttp://www.dotnetperls.com/trimend-vbnethttp://www.dotnetperls.com/trim-vbnethttp://www.dotnetperls.com/lastindexofany-vbnethttp://www.dotnetperls.com/lastindexof-vbnethttp://www.dotnetperls.com/indexofany-vbnethttp://www.dotnetperls.com/indexof-vbnethttp://www.dotnetperls.com/contains-vbnet
  • 7/31/2019 Vb.net String

    4/5

    The ROT13 encoding algorithm is a clever method that shifts the letters in the alphabet by 13

    places in two directions based on their values. It is easily reversed. We present a complete

    implementation in the VB.NET language.

    ROT13

    Convert

    It is often necessary to convert Strings to other types, such as Integers. Conversely, most types

    can be converted to Strings with ToString. We examine String conversions.

    CStrChar Array to StringList to StringString Array to StringString to Integer

    Select Case

    A String instance can be used in a Select Case statement in the VB.NET language. A logical

    decision is made based on the String's character data.

    Select Case

    Summary

    The String type in the VB.NET language is powerful, but also has some limitations. In situations

    where you can improve performance by mutating an existing string, you will need to use an

    alternative type such as StringBuilder.

    Note: Strings in the VB.NET language cannot be changed after they are created.

    http://www.dotnetperls.com/rot13-vbnethttp://www.dotnetperls.com/rot13-vbnethttp://www.dotnetperls.com/cstrhttp://www.dotnetperls.com/convert-char-array-string-vbnethttp://www.dotnetperls.com/convert-char-array-string-vbnethttp://www.dotnetperls.com/convert-list-string-vbnethttp://www.dotnetperls.com/convert-list-string-vbnethttp://www.dotnetperls.com/convert-string-array-string-vbnethttp://www.dotnetperls.com/convert-string-array-string-vbnethttp://www.dotnetperls.com/convert-string-integerhttp://www.dotnetperls.com/convert-string-integerhttp://www.dotnetperls.com/convert-string-integerhttp://www.dotnetperls.com/select-case-string-vbnethttp://www.dotnetperls.com/select-case-string-vbnethttp://www.dotnetperls.com/vbhttp://www.dotnetperls.com/vbhttp://www.dotnetperls.com/vbhttp://www.dotnetperls.com/vbhttp://www.dotnetperls.com/vbhttp://www.dotnetperls.com/vbhttp://www.dotnetperls.com/vbhttp://www.dotnetperls.com/vbhttp://www.dotnetperls.com/vbhttp://www.dotnetperls.com/select-case-string-vbnethttp://www.dotnetperls.com/convert-string-integerhttp://www.dotnetperls.com/convert-string-array-string-vbnethttp://www.dotnetperls.com/convert-list-string-vbnethttp://www.dotnetperls.com/convert-char-array-string-vbnethttp://www.dotnetperls.com/cstrhttp://www.dotnetperls.com/rot13-vbnet
  • 7/31/2019 Vb.net String

    5/5

    .NET

    http://www.dotnetperls.com/vbhttp://www.dotnetperls.com/vbhttp://www.dotnetperls.com/vb