Results 1 to 9 of 9

Thread: vb6 random file in .net

  1. #1

    Thread Starter
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176

    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
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    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

  3. #3

    Thread Starter
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176

    Re: vb6 random file in .net

    ooo thanks will give it a go

    Thanks
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    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.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    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.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  8. #8

    Thread Starter
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176

    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
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  9. #9
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: vb6 random file in .net

    Cough (XML)
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width