VBFixedStringAttribute 類別
表示字串應該視為具有固定長度。
命名空間: Microsoft.VisualBasic
組件: Microsoft.VisualBasic (在 microsoft.visualbasic.dll 中)
語法
'宣告
<AttributeUsageAttribute(AttributeTargets.Field, Inherited:=False, AllowMultiple:=False)> _
Public NotInheritable Class VBFixedStringAttribute
Inherits Attribute
'用途
Dim instance As VBFixedStringAttribute
[AttributeUsageAttribute(AttributeTargets.Field, Inherited=false, AllowMultiple=false)]
public sealed class VBFixedStringAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Field, Inherited=false, AllowMultiple=false)]
public ref class VBFixedStringAttribute sealed : public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Field, Inherited=false, AllowMultiple=false) */
public final class VBFixedStringAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.Field, Inherited=false, AllowMultiple=false)
public final class VBFixedStringAttribute extends Attribute
備註
如需詳細資訊,請參閱 Visual Basic 的主題 VBFixedStringAttribute 類別。
Visual Basic 字串預設有變動的長度。當使用需要固定長度字串的 Visual Basic 檔案輸入和輸出函式 (例如 FileGet 和 FilePut) 時,這個屬性會很有用處。
範例
Structure Person
Public ID As Integer
Public MonthlySalary As Decimal
Public LastReviewDate As Long
<VBFixedString(15)> Public FirstName As String
<VBFixedString(15)> Public LastName As String
<VBFixedString(15)> Public Title As String
<VBFixedString(150)> Public ReviewComments As String
End Structure
注意事項 |
---|
VBFixedStringAttribute 僅供參考,所以不能用來將變動長度的字串轉換成固定長度。這個屬性的目的是要修改可辨識 VBFixedStringAttribute 的方法或 API 呼叫要如何使用結構和非區域變數中的字串。請牢記,這個屬性並不會變更字串本身的實際長度。 |
繼承階層架構
System.Object
System.Attribute
Microsoft.VisualBasic.VBFixedStringAttribute
執行緒安全
這個型別的所有公用靜態成員 (即 Visual Basic 中的 Shared 成員) 都是安全執行緒。並非所有的執行個體成員均為安全執行緒。
平台
Windows 98、 Windows 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
.NET Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱系統需求一節的內容。
版本資訊
.NET Framework
支援版本:2.0、1.1、1.0
.NET Compact Framework
支援版本:2.0、1.0
請參閱
參考
VBFixedStringAttribute 成員
Microsoft.VisualBasic 命名空間
StringBuilder
MarshalAsAttribute
其他資源
VBFixedStringAttribute 類別
Visual Basic 中的屬性
VBFixedStringAttribute 類別成員
VBFixedArrayAttribute 類別
ComClassAttribute 類別
Visual Basic 所用的屬性
FileGet 函式
FilePut 函式
FileOpen 函式