|
-
Feb 4th, 2008, 10:21 AM
#1
Thread Starter
KING BODWAD XXI
vb6 random file in .net
Ok I know you lot will think this is a retarded question but how I go about reading in an old VB6 format random file?
The original type used was as follows
Code:
Type MainDB
Artist As String * 50
SongTitle As String * 50
Category As String * 30
TrackID As String * 25
SongFilename As String * 90
AlbumFilename As String * 90
DateDownloaded As Date
End Type
Now I know about these ones:
Longs = Integers
Integers = Short
but how do I convert the fixed length strings when it isnt available? How am I supposed to read in the old file format? I tried using an array of chars but it says I cant fix length the arrays in structures. Does this mean I have to set their length at runtime and then go from there?
thanks,
A rather silly mutt
-
Feb 4th, 2008, 10:36 AM
#2
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
-
Feb 4th, 2008, 10:45 AM
#3
Thread Starter
KING BODWAD XXI
Re: vb6 random file in .net
ooo thanks will give it a go 
Thanks
-
Feb 4th, 2008, 09:36 PM
#4
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.
-
Feb 4th, 2008, 10:04 PM
#5
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.
-
Feb 4th, 2008, 10:34 PM
#6
Re: vb6 random file in .net
 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.
 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.
-
Feb 5th, 2008, 05:55 AM
#7
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.
-
Feb 5th, 2008, 10:09 AM
#8
Thread Starter
KING BODWAD XXI
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
-
Feb 5th, 2008, 10:26 AM
#9
Re: vb6 random file in .net
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|