FixedLengthString Constructors
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Initializes a new instance of the FixedLengthString class.
Overloads
FixedLengthString(Int32) |
Initializes a new instance of the FixedLengthString class, specifying the length. |
FixedLengthString(Int32, String) |
Initializes a new instance of the FixedLengthString class, specifying the length and the initial value. |
FixedLengthString(Int32)
Initializes a new instance of the FixedLengthString class, specifying the length.
public:
FixedLengthString(int MaxChars);
public FixedLengthString (int MaxChars);
new Microsoft.VisualBasic.Compatibility.VB6.FixedLengthString : int -> Microsoft.VisualBasic.Compatibility.VB6.FixedLengthString
Public Sub New (MaxChars As Integer)
Parameters
- MaxChars
- Int32
An Integer
that specifies the length of the string.
Examples
The following example demonstrates how to declare and use a FixedLengthString.
Private Sub DemoFixedLengthString()
' Declare a string that has a length of 7 characters.
Dim fixedString As New FixedLengthString(7)
' Assign a value to the string.
fixedString.Value = "Hello World"
' Display the string in a message box.
' Note that only the first 7 characters are shown.
MsgBox(fixedString.ToString)
End Sub
Remarks
In Visual Basic 6.0, you can specify the length of a string in its declaration. In Visual Basic, you cannot declare a string to have a fixed length unless you use the VBFixedStringAttribute attribute in the declaration.
Use this class to declare a fixed-length string without using the attribute.
Note
Functions and objects in the Microsoft.VisualBasic.Compatibility.VB6 namespace are provided for use by the tools for upgrading from Visual Basic 6.0 to Visual Basic 2008. In most cases, these functions and objects duplicate functionality that you can find in other namespaces in the .NET Framework. They are necessary only when the Visual Basic 6.0 code model differs significantly from the .NET Framework implementation.
Applies to
FixedLengthString(Int32, String)
Initializes a new instance of the FixedLengthString class, specifying the length and the initial value.
public:
FixedLengthString(int MaxChars, System::String ^ InitialValue);
public FixedLengthString (int MaxChars, string InitialValue);
new Microsoft.VisualBasic.Compatibility.VB6.FixedLengthString : int * string -> Microsoft.VisualBasic.Compatibility.VB6.FixedLengthString
Public Sub New (MaxChars As Integer, InitialValue As String)
Parameters
- MaxChars
- Int32
An Integer
that specifies the length of the string.
Examples
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
Remarks
In Visual Basic 6.0, you can specify the length of a string in its declaration. In Visual Basic, you cannot declare a string to have a fixed length unless you use the VBFixedStringAttribute attribute in the declaration.
Use this class to declare a fixed length string without using the attribute.
Note
Functions and objects in the Microsoft.VisualBasic.Compatibility.VB6 namespace are provided for use by the tools for upgrading from Visual Basic 6.0 to Visual Basic 2008. In most cases, these functions and objects duplicate functionality that you can find in other namespaces in the .NET Framework. They are necessary only when the Visual Basic 6.0 code model differs significantly from the .NET Framework implementation.