C# to vb .net (2005) help


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: C# to vb .net (2005) help

  1. #1
    Join Date
    Dec 2006
    Posts
    30

    C# to vb .net (2005) help

    help me to convert the following c# code in vb .net (2.0)

    do {
    while (bl_counts[--incrBitLen] == 0);
    do {
    bl_counts[incrBitLen]--;
    bl_counts[++incrBitLen]++;
    overflow -= 1 << (maxLength - 1 - incrBitLen);
    }
    while (overflow > 0 && incrBitLen < maxLength - 1);
    }

    what is the meaning of while loop without curly braces in c#

    awaiting reply.

    Thanks
    Javfarary

  2. #2
    Join Date
    Jul 2004
    Posts
    81
    As I mentioned in another forum, the code you posted won't compile - your outer 'do' loop needs some condition (you can't have a conditionless 'do' loop in C#).

    Here is an attempt to format your code to determine where your problem lies:

    do //this 'do' loop needs a condition (either here or at the end)
    {
    //this is an empty while loop (perfectly legit):
    while (bl_counts[--incrBitLen] == 0);

    do
    {
    bl_counts[incrBitLen]--;
    bl_counts[++incrBitLen]++;
    overflow -= 1 << (maxLength - 1 - incrBitLen);
    } while (overflow > 0 && incrBitLen < maxLength - 1);
    //syntax error - you cannot close a simple 'do' loop like this in C#:
    }

    Regarding the loop without braces, it's just a loop that only executes 'header' logic under the condition is met.
    David Anton
    Convert between VB, C#, C++, & Java
    www.tangiblesoftwaresolutions.com
    Instant C# - VB to C# Converter
    Instant VB - C# to VB Converter

  3. #3
    Join Date
    Dec 2006
    Posts
    30
    Thanks for the help, I got the while loop working in vb now. thanks

    and what about this code...

    if (windowFilled++ == WindowSize)
    {
    throw new InvalidOperationException("Window full");
    }

    if the condition is true then only windowFilled++?
    Please convert it to vb.

    Thanks
    Javfarary

  4. #4
    Join Date
    Jul 2004
    Posts
    81
    'windowFilled' is incremented after the conditional test, regardless of whether the test is true or false.
    David Anton
    Convert between VB, C#, C++, & Java
    www.tangiblesoftwaresolutions.com
    Instant C# - VB to C# Converter
    Instant VB - C# to VB Converter

  5. #5
    Join Date
    Dec 2006
    Posts
    30
    OK. Thanks for the help.

Similar Threads

  1. Need Books on VS .Net, VB .net, ASP.net
    By Jim Underwood in forum .NET
    Replies: 3
    Last Post: 02-28-2002, 09:45 PM
  2. More on Visual J#.Net
    By Jim Pragit in forum .NET
    Replies: 64
    Last Post: 10-20-2001, 08:06 PM
  3. A moderate view.
    By Paul Mc in forum .NET
    Replies: 214
    Last Post: 06-01-2001, 07:27 AM
  4. Re: VB or Powerbuilder?
    By Jean-Yves in forum Enterprise
    Replies: 3
    Last Post: 06-01-2000, 12:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center