Re: vb6 random file in .net
Try this:
Code:
Public Structure MainDB
<VBFixedString(50)> Dim Artist As String
<VBFixedString(50)> Dim SongTitle As String
<VBFixedString(30)> Dim Category As String
<VBFixedString(25)> Dim TrackID As String
<VBFixedString(90)> Dim SongFilename As String
<VBFixedString(90)> Dim AlbumFilename As String
Dim DateDownloaded As Date
End Structure
Re: vb6 random file in .net
ooo thanks will give it a go :)
Thanks
Re: vb6 random file in .net
Just be aware that there actually isn't such thing as a fixed length string in VB.NET. The VBFixedString attribute makes a string APPEAR as though it's a fixed length string when interoperating with VB6 code. If you're not actually passing the string to VB6 code then the attribute is pointless.
Re: vb6 random file in .net
A string is an array of characters - so you can have a fixed length string. It may be necessary to use them when communicating with kernel / API functions in the form of buffers.
Re: vb6 random file in .net
Quote:
Originally Posted by visualAd
A string is an array of characters - so you can have a fixed length string. It may be necessary to use them when communicating with kernel / API functions in the form of buffers.
I'm talking about the .NET System.String class.
Quote:
Originally Posted by MSDN
The VBFixedStringAttribute is informational and cannot be used to convert a variable length string to a fixed string. The purpose of this attribute is to modify how strings in structures and non-local variables are used by methods or API calls that recognize the VBFixedStringAttribute, such as the Len and FilePut functions. Keep in mind that this attribute does not change the actual length of the string itself.
There is no way inherent in the type to specify that a String variable will refer to a String object of a specific length. Even with the VBFixedLength attribute applied you can assign String objects of any length to that variable. All String objects are a fixed length in that, once created, they are immutable. That's got no relationship to that attribute though.
Re: vb6 random file in .net
When you declare an array in .NET it must be of fixed length; well not fixed as it must be a constant but fixed as in it must have an initial size. As a String is synonymous with an array of characters; it is possible to have a fixed length string in that sense.
I understand that System.String has not concept of a fixed length string and I cannot understand why someone would want to use an array of characters in its places except for when communicating with lower level functions.
Re: vb6 random file in .net
Yep thanks. I found a way of doing it without fixed length strings using the binaryreader. Its a right hastle though, what happened to the good old days where it was one line of code to get a type structure from a file :p
Re: vb6 random file in .net