FixedLengthString Class

Emulates the behavior of a Visual Basic 6.0 fixed-length string.

Namespace: Microsoft.VisualBasic.Compatibility.VB6
Assembly: Microsoft.VisualBasic.Compatibility (in microsoft.visualbasic.compatibility.dll)

public class FixedLengthString
public class FixedLengthString
public class FixedLengthString
Not applicable.

In Visual Basic 6.0, a String could be declared with a fixed length. In Visual Basic Code Name "Orcas", fixed-length strings are no longer supported and a new String is allocated every time the length of the String is changed.

The FixedLengthString class can be used to emulate the behavior of a Visual Basic 6.0 string, which enables you to declare a string with a fixed length. A FixedLengthString cannot be converted to a String; you must either reference the Value property or call the ToString method to convert the type.

The following example demonstrates how to declare and use a FixedLengthString.

Private Sub DemoFixedLengthString()
    ' Declare a string that has a length of 7 characters and assign the
    ' initial string. The additional 5 positions will be padded with
    ' spaces.
    Dim fixedString As New FixedLengthString(7, "He")
    ' Display the string in a message box.
    MsgBox(fixedString.ToString)
    ' Assign a new value to the string.
    fixedString.Value = "Hello World"
    ' Display again. Note that only the first 7 characters are shown.
    MsgBox(fixedString.ToString)
End Sub

System.Object
  Microsoft.VisualBasic.Compatibility.VB6.FixedLengthString

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show: