Results 1 to 6 of 6

Thread: [RESOLVED] Converting code question?

  1. #1

    Thread Starter
    PowerPoster VBDT's Avatar
    Join Date
    Sep 2005
    Location
    CA - USA
    Posts
    2,922

    Resolved [RESOLVED] Converting code question?

    Hi guys, I use VB.Net and I need to convert this VB 6 code to VB.Net.
    vb Code:
    1. Type WAVEINCAPS
    2.    wMid As Integer
    3.    wPid As Integer
    4.    vDriverVersion As Long
    5.    szPname As String * 32
    6.    dwFormats As Long
    7.    wChannels As Integer
    8. End Type
    The only problem I have is this line
    vb Code:
    1. szPname As String * 32
    Is this some sort of indication of a size?
    Thanks in advance!

  2. #2
    Addicted Member Kal-El's Avatar
    Join Date
    Jun 2007
    Location
    Fortress of solitude
    Posts
    179

    Re: Converting code question?

    I think you are in the wrong forum...but my small knowladge of VB. net tells me that you need to see something about Marshal to allocate stuff, see this, translated in to something like this:
    vbnet Code:
    1. Dim MyPointer As string =  Marshal.AllocHGlobal(4)
    2. Marshal.WriteInt32(MyPointer, 255)
    3.  ' some more code here (call to
    4. ' unmanaged code for example)
    5.  ' free memory
    6. Marshal.FreeHGlobal(MyPointer)
    Note: Code not tested

    «Source Code»«plugins»«skin»«fav apps»«Winamp en español»«Nsis en español»
    So what if your signature move is driving a tractor? I think it's adorable. - Lois ("Crimson")
    Don't forget to when your question is resolved ...and the people who help

  3. #3
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: Converting code question?

    Yes that is an indicator of size. It dimensions a string 32 bytes long.
    for that one line, here is the equivalent vb.net line:
    Code:
    <VBFixedString(33),System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray,SizeConst:=32)> Public szPName() As Char
    note that i have it set to 33. that is because a string has a terminating null bit, and marshallas doesn't take that into account and you have to manually set it.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  4. #4

    Thread Starter
    PowerPoster VBDT's Avatar
    Join Date
    Sep 2005
    Location
    CA - USA
    Posts
    2,922

    Re: Converting code question?

    Thank you Lord Orwell. That is what I was thinking. One more question, Is VBFixedString(33) needed? I saw a C# example that didn't have VBFixedString class instance.

  5. #5
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: Converting code question?

    i am by no means an expert, but that is supposedly how it knows what size to make the fixed string.
    I have no idea what you are using the structure for, so i can't say any more than that.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  6. #6

    Thread Starter
    PowerPoster VBDT's Avatar
    Join Date
    Sep 2005
    Location
    CA - USA
    Posts
    2,922

    Re: Converting code question?

    Well, I am tring to use this structure in "waveInGetDevCaps" Api function. The reason I ask because I saw a C# example that didn't have VBFixedString class instance. Anyways thank you very much.

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