VBFixedStringAttribute Attribute

 <  Day Day Up  >  

The VBFixedStringAttribute attribute is used to ensure that files written using the FileSystem methods are compatible with previous versions of Visual Basic. A fixed- size string in previous versions of Visual Basic was a string declared with a fixed size in a user -defined type.

 Type Team   Name As String * 10 End Type 

This example shows a user-defined type with a fixed-size string of length 10 in it. When a user-defined type with a fixed-size string was written to disk, it included a special header containing the size of the string. For the string to be read properly in Visual Basic .NET, the corresponding class or structure has to specify the VBFixedStringAttribute .

 Class Team   <VBFixedStringAttribute(10)> Public Name As String End Class Module Test   Sub Main()     Dim x As Team     FileOpen(FileNum, "team.txt", OpenMode.Binary, _       OpenAccess.Write, OpenShare.Default)     FileGet(1, x)     FileClose(1)   End Sub End Module Public ReadOnly Length() As Integer 

The Length property returns the number of characters in the fixed-size string.

 Public Sub New(ByVal Length As Integer) 

The VBFixedStringAttribute constructor specifies the length of the fixed-size string.

 <  Day Day Up  >  


The Visual Basic .NET Programming Language
The Visual Basic .NET Programming Language
ISBN: 0321169514
EAN: 2147483647
Year: 2004
Pages: 173
Authors: Paul Vick

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net