Results 1 to 6 of 6

Thread: VB6.0 Type, to VB.NET Structure

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,794

    VB6.0 Type, to VB.NET Structure

    How do I convert the following type to VB.NET ?
    VB Code:
    1. Public Const ACMFORMATTAGDETAILS_FORMATTAG_CHARS = 48
    2.  
    3. Public Type tACMFORMATTAGDETAILS
    4.     cbStruct As Long
    5.     dwFormatTagIndex As Long
    6.     dwFormatTag As Long
    7.     cbFormatSize As Long
    8.     fdwSupport As Long
    9.     cStandardFormats As Long
    10.     szFormatTag(ACMFORMATTAGDETAILS_FORMATTAG_CHARS - 1) As Byte
    11. End Type
    This is what I got:
    VB Code:
    1. Public Structure tACMFORMATTAGDETAILS
    2.         Public cbStruct As Integer
    3.         Public dwFormatTagIndex As Integer
    4.         Public dwFormatTag As Integer
    5.         Public cbFormatSize As Integer
    6.         Public fdwSupport As Integer
    7.         Public cStandardFormats As Integer
    8.         [COLOR=Red]Public szFormatTag(ACMFORMATTAGDETAILS_FORMATTAG_CHARS - 1) As Byte[/COLOR]
    9.     End Structure
    But I got an error on the red line

  2. #2
    Frenzied Member conipto's Avatar
    Join Date
    Jun 2005
    Location
    Chicago
    Posts
    1,175

    Re: VB6.0 Type, to VB.NET Structure

    Does it have to be a structure? If you change it to a class it should work.. I don't know if you can get around the rule about structures not having pre-declared array sizes.

    Bill
    Hate Adobe Acrobat? My Codebank Sumbissions - Easy CodeDom Expression evaluator: (VB / C# ) -- C# Scrolling Text Display

    I Like to code when drunk. Don't say you weren't warned.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,794

    Re: VB6.0 Type, to VB.NET Structure

    It has to be a structure because I need this for an API call...

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,794

    Re: VB6.0 Type, to VB.NET Structure

    Nevermind, I think I figured it out:
    VB Code:
    1. <StructLayout(LayoutKind.Sequential, Pack:=1)> Public Structure tACMFORMATTAGDETAILS
    2.         Public cbStruct As Integer
    3.         Public dwFormatTagIndex As Integer
    4.         Public dwFormatTag As Integer
    5.         Public cbFormatSize As Integer
    6.         Public fdwSupport As Integer
    7.         Public cStandardFormats As Integer
    8.         <MarshalAs(UnmanagedType.ByValArray, SizeConst:=ACMFORMATTAGDETAILS_FORMATTAG_CHARS)> Public szFormatTag() As Byte
    9.     End Structure

  5. #5
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,467

    Re: VB6.0 Type, to VB.NET Structure

    Just a note about naming conventions. .NET structures are named just like classes by convention, e.g. AcmFormatTagDetails. All upper case is usually used for constants. What conventions you use are up to you though, obviously.

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,794

    Re: VB6.0 Type, to VB.NET Structure

    Thanks for your input.
    Yes, I usually don't use upper case for structures when I make my own structures.

    I'm converting code from a VB6 application, I want to make an application using Audio Compression Manager (ACM), and I just copy & paste code from VB6 and trying to convert the code. And even the types (structures) in VB6 they come from MSDN (from C++) where they all are in upper case.

    I will probally be asking a few more questions on converting VB6 to VB.NET in the near future.

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