Results 1 to 12 of 12

Thread: C# to VB6

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    C# to VB6

    Hello, the past few weeks I have been looking for a way to find out whether an AVI video has been encoded with options like Quarter Pixel, S(GMC)-VOP, B-VOP, etc. Unfortunately there is no information or example code in VB6 that shows how to get this information from an AVI video.

    On doom9.org the author of an application named MPEG4 Modifier told me to look at the source code, but it's written in C# and I don't understand that language. Spending months on learning a new language (which I will probably never use) just to get some source code is a bit too much.

    Is there somebody here who knows both languages and maybe wants to translate the parts I need to VB6 ?

    The parts I need are ParseVOL() and ParseVOP(). The flag for Quarter Pixel is stored in vol.quarterpel, and the frame type is in vop.vop_type.

    Thank you.
    Last edited by Chris001; Sep 12th, 2010 at 12:37 PM.

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Quote Originally Posted by Chris001
    (which I will probably never use)
    Sorry but this is NOT true . If you learn C# , you'd forget VB6 at all . I know this never answered your question but i just couldn't ignore this .

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

    Re: C# to VB6

    There's a link to a C# to VB.NET converter in my sig. Once you have VB.NET code you may well be able to convert a lot of it to VB6 yourself.
    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

  4. #4
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: C# to VB6

    Quote Originally Posted by Pirate
    Sorry but this is NOT true . If you learn C# , you'd forget VB6 at all . I know this never answered your question but i just couldn't ignore this .
    Perhaps you are right since I am already using // to comment in VB6.0!
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: C# to VB6

    Thanks jmcilhinney, I tried the C# to VB.NET converter, but it gives me this error message:

    An error occured while processing your code: The number style AllowHexSpecifier is not supported on floating point data types.
    I have no idea what it means.

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

    Re: C# to VB6

    Where in the code does this occur? Post the relevant code, but post just the relevant section in VBCODE tags so it's visible in your post rather than downloading a file.
    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

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: C# to VB6

    Sorry, I should have mentioned that. It shows the error message on the C# to VB.NET converter webpage.



    The problem is also that I don't really know which part of the code I exactly need. C# is like Chinese to me, that's why I posted the complete code.

    I think this is what I need. It's still a lot of code though.

    VB Code:
    1. private byte[] ParseVOP(byte[] data, bool modify) {
    2.             BitStream bits, bitsOut;
    3.             VOLInfo vol = _vol;
    4.             VOPInfo vop = new VOPInfo();
    5.  
    6.             bits = new BitStream(data);
    7.             if (modify) {
    8.                 bitsOut = new BitStream(data.Length);
    9.                 bits.CopyDest = bitsOut;
    10.             }
    11.             else {
    12.                 bitsOut = null;
    13.             }
    14.  
    15.             bits.Copy(32);
    16.             vop.coding_type = bits.Copy(2);
    17.  
    18.             while (bits.Copy(1) == 1) {
    19.                 vop.modulo_time_base++;
    20.             }
    21.             bits.Copy(1);
    22.  
    23.             vop.time_inc = bits.Copy(vol.time_inc_bits);
    24.             bits.Copy(1);
    25.  
    26.             vop.coded = ToBool(bits.Copy(1));
    27.             vop.vop_type = vop.coded ? (VOPType)vop.coding_type : VOPType.N_VOP;
    28.             vop.is_reference_vop = vop.coded && (vop.vop_type != VOPType.B_VOP);
    29.             if (vop.coded) {
    30.                 if (vol.newpred_enable) {
    31.                     int vop_id_bits = Math.Min(vol.time_inc_bits + 3, 15);
    32.  
    33.                     bits.Copy(vop_id_bits);
    34.                     if (bits.Copy(1) == 1) {
    35.                         bits.Copy(vop_id_bits);
    36.                     }
    37.                     bits.Copy(1);
    38.                 }
    39.  
    40.                 if ( (vol.shape != (uint)VOLShape.BinaryOnly) &&
    41.                     ( (vop.coding_type == (uint)VOPType.P_VOP) ||
    42.                     ( (vop.coding_type == (uint)VOPType.S_VOP) && (vol.sprite_enable == (uint)Sprite.GMC) ) ) )
    43.                 {
    44.                     bits.Copy(1);
    45.                 }
    46.  
    47.                 if ( vol.reduced_resolution_enable &&
    48.                     (vol.shape == (uint)VOLShape.Rectangular) &&
    49.                     ( (vop.coding_type == (uint)VOPType.P_VOP) || (vop.coding_type == (uint)VOPType.I_VOP) ) )
    50.                 {
    51.  
    52.                     bits.Copy(1);
    53.                 }
    54.  
    55.                 if (vol.shape != (uint)VOLShape.Rectangular) {
    56.                     if ( !( (vol.sprite_enable == (uint)Sprite.Static) &&
    57.                         (vop.coding_type == (uint)VOPType.I_VOP) ) )
    58.                     {
    59.                         // 56 bits
    60.                         bits.Copy(32);
    61.                         bits.Copy(24);
    62.                     }
    63.                     bits.Copy(1);
    64.                     if (bits.Copy(1) == 1) {
    65.                         bits.Copy(8);
    66.                     }
    67.                 }
    68.  
    69.                 if (vol.shape != (uint)VOLShape.BinaryOnly) {
    70.                     bits.Copy(3);
    71.                     if (vol.interlaced) {
    72.                         vop.top_field_first = ToBool(bits.Read(1));
    73.                         if (modify) {
    74.                             bitsOut.Write( (_tff ? 1U : 0U) , 1);
    75.                         }
    76.                         bits.Copy(1);
    77.                     }
    78.                 }
    79.  
    80.                 if ( (vol.sprite_enable != (uint)Sprite.None) &&
    81.                     (vop.coding_type == (uint)VOPType.S_VOP) )
    82.                 {
    83.                     vop.warping_points_used = 0;
    84.  
    85.                     for (int i = 1; i <= vol.sprite_warping_points; i++) {
    86.                         bool x_used = CopyWarpingCode(bits);
    87.                         bool y_used = CopyWarpingCode(bits);
    88.  
    89.                         if (x_used || y_used) {
    90.                             vop.warping_points_used = (uint)i;
    91.                         }
    92.                     }
    93.                 }
    94.             }
    95.  
    96.             if (modify) {
    97.                 while (bits.Remaining > 0) {
    98.                     bits.Copy(Math.Min(bits.Remaining, 32));
    99.                 }
    100.             }
    101.  
    102.             _vop = vop;
    103.             return modify ? bitsOut.GetBytes(bitsOut.Position / 8) : null;
    104.         }
    105.  
    106.         private byte[] ParseVOL(byte[] data, bool modify) {
    107.             BitStream bits, bitsOut;
    108.             VOLInfo vol = new VOLInfo();
    109.  
    110.             bits = new BitStream(data);
    111.             if (modify) {
    112.                 bitsOut = new BitStream(data.Length + 16);
    113.                 bits.CopyDest = bitsOut;
    114.             }
    115.             else {
    116.                 bitsOut = null;
    117.             }
    118.  
    119.             bits.Copy(32);
    120.             bits.Copy(9);
    121.  
    122.             if (bits.Copy(1) == 1) {
    123.                 vol.ver_id = bits.Copy(4);
    124.                 bits.Copy(3);
    125.             }
    126.             else {
    127.                 vol.ver_id = 1;
    128.             }
    129.  
    130.             // Read PAR info
    131.             vol.aspect_ratio = bits.Read(4);
    132.             if (vol.aspect_ratio == (uint)PARType.Custom) {
    133.                 vol.par_width  = bits.Read(8);
    134.                 vol.par_height = bits.Read(8);
    135.             }
    136.  
    137.             // Write new PAR info
    138.             if (modify) {
    139.                 bitsOut.Write((uint)_parInfo.Type, 4);
    140.                 if (_parInfo.Type == PARType.Custom) {
    141.                     bitsOut.Write(_parInfo.Width, 8);
    142.                     bitsOut.Write(_parInfo.Height, 8);
    143.                 }
    144.             }
    145.  
    146.             if (bits.Copy(1) == 1) {
    147.                 bits.Copy(3);
    148.                 if (bits.Copy(1) == 1) {
    149.                     // 79 bits
    150.                     bits.Copy(32);
    151.                     bits.Copy(32);
    152.                     bits.Copy(15);
    153.                 }
    154.             }
    155.  
    156.             vol.shape = bits.Copy(2);
    157.             if ((vol.ver_id != 1) && (vol.shape == (uint)VOLShape.Grayscale)) {
    158.                 bits.Copy(4);
    159.             }
    160.             bits.Copy(1);
    161.  
    162.             vol.time_inc_res = bits.Copy(16);
    163.             vol.time_inc_bits = Math.Max(BitsUsed(vol.time_inc_res - 1), 1);
    164.             bits.Copy(1);
    165.  
    166.             if (bits.Copy(1) == 1) {
    167.                 bits.Copy(vol.time_inc_bits);
    168.             }
    169.  
    170.             if (vol.shape != (uint)VOLShape.BinaryOnly) {
    171.                 if (vol.shape == (uint)VOLShape.Rectangular) {
    172.                     bits.Copy(29);
    173.                 }
    174.  
    175.                 vol.interlaced = ToBool(bits.Copy(1));
    176.                 bits.Copy(1);
    177.  
    178.                 vol.sprite_enable = bits.Copy( vol.ver_id == 1 ? 1 : 2 );
    179.                 if (vol.sprite_enable != (uint)Sprite.None) {
    180.                     if (vol.sprite_enable == (uint)Sprite.Static) {
    181.                         // 56 bits
    182.                         bits.Copy(32);
    183.                         bits.Copy(24);
    184.                     }
    185.  
    186.                     vol.sprite_warping_points = bits.Copy(6);
    187.                     if (vol.sprite_warping_points > 4) {
    188.                         throw new Exception("Invalid VOL (too many warping points)");
    189.                     }
    190.  
    191.                     bits.Copy(3);
    192.                     if (vol.sprite_enable == (uint)Sprite.Static) {
    193.                         bits.Copy(1);
    194.                     }
    195.                 }
    196.  
    197.                 if ((vol.ver_id != 1) && (vol.shape != (uint)VOLShape.Rectangular)) {
    198.                     bits.Copy(1);
    199.                 }
    200.  
    201.                 if (bits.Copy(1) == 1) {
    202.                     bits.Copy(8);
    203.                 }
    204.  
    205.                 if (vol.shape == (uint)VOLShape.Grayscale) {
    206.                     bits.Copy(3);
    207.                 }
    208.  
    209.                 vol.mpeg_quant = ToBool(bits.Copy(1));
    210.                 if (vol.mpeg_quant) {
    211.                     vol.load_intra_quant_mat = ToBool(bits.Copy(1));
    212.                     if (vol.load_intra_quant_mat) {
    213.                         vol.intra_quant_mat = CopyQuantMatrix(bits);
    214.                     }
    215.  
    216.                     vol.load_inter_quant_mat = ToBool(bits.Copy(1));
    217.                     if (vol.load_inter_quant_mat) {
    218.                         vol.inter_quant_mat = CopyQuantMatrix(bits);
    219.                     }
    220.  
    221.                     if (vol.shape == (uint)VOLShape.Grayscale) {
    222.                         throw new Exception("Grayscale matrix isn't supported");
    223.                     }
    224.                 }
    225.  
    226.                 if (vol.ver_id != 1) {
    227.                     vol.quarterpel = ToBool(bits.Copy(1));
    228.                 }
    229.  
    230.                 if (bits.Copy(1) == 0) {
    231.                     throw new Exception("Complexity estimation isn't supported");
    232.                 }
    233.                 bits.Copy(1);
    234.  
    235.                 if (bits.Copy(1) == 1) {
    236.                     bits.Copy(1);
    237.                 }
    238.  
    239.                 if (vol.ver_id != 1) {
    240.                     vol.newpred_enable = ToBool(bits.Copy(1));
    241.                     if (vol.newpred_enable) {
    242.                         bits.Copy(3);
    243.                     }
    244.                     vol.reduced_resolution_enable = ToBool(bits.Copy(1));
    245.                 }
    246.  
    247.                 if (bits.Copy(1) == 1) {
    248.                     throw new Exception("Scalability isn't supported");
    249.                 }
    250.             }
    251.             else {
    252.                 if (vol.ver_id != 1) {
    253.                     if (bits.Copy(1) == 1) {
    254.                         throw new Exception("Scalability isn't supported");
    255.                     }
    256.                 }
    257.                 bits.Copy(1);
    258.             }
    259.  
    260.             // Check padding (padding should be present even if the data already ends on
    261.             // a byte boundary, but if there's no padding we will just ignore it)
    262.             if ((bits.Remaining < 0) || (bits.Remaining > 8)) {
    263.                 throw new Exception("Invalid VOL");
    264.             }
    265.             bits.Copy(bits.Remaining);
    266.  
    267.             _vol = vol;
    268.             return modify ? bitsOut.GetBytes(bitsOut.Position / 8) : null;
    269.         }

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

    Re: C# to VB6

    I suggest that you just try to convert small chunks at a time on those converters. First of you could remove the contents of the method and just convert the declaration, then the variable declarations at the top, then each little chunk one at a time. That way you can build up your VB.NET code bit by bit and deal with each specific issue as it arises. Honestly, C# is not really all that different to VB.NET, or at least the translation from one to the other is relatively clear once you know a few basic rules. Like so many things, you just need to break the large problem down into a series of smaller problems.
    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

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: C# to VB6

    Thanks for your help, jmcilhinney

  10. #10
    Fanatic Member Slaine's Avatar
    Join Date
    Jul 2002
    Posts
    641

    Re: C# to VB6

    You could always try compiling it then decompiling it to VB.Net using something like Reflector

    That should get you something to start from.
    Martin J Wallace (Slaine)

  11. #11
    New Member
    Join Date
    Mar 2007
    Posts
    8

    Re: C# to VB6

    hi, I'm having the exact sample problem converting from C# to VB.NET...
    An error occured while processing your code: The number style AllowHexSpecifier is not supported on floating point data types

    It's failing at these two lines:
    int data_len = (waveInput.Length - 0x2c);
    Buffer.BlockCopy(waveInput, 0x2c, data, 0, data_len);

    I don't know C#.NET at all and not much of VB.NET
    Can anyone help me?

  12. #12
    New Member
    Join Date
    Mar 2007
    Posts
    8

    Re: C# to VB6

    sorry, same problem*

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