SgDotNet
Singapore Professional .NET User Group -For Cool Developers

Visual Basic 9: Standing Proud

rated by 0 users
This post has 16 Replies | 3 Followers

Top 10 Contributor
Posts 865
Softwaremaker Posted: 09-20-2005 2:28 PM

It is ok, folks. It is our time now. We can stand with our heads up high today. Get ready to roar.

Dump C# today Wink [;)]

~Softwaremaker (BLOG) M. Twain: "I didn't have time to write a short letter, so I wrote a long one instead"

Top 25 Contributor
Posts 442
 Softwaremaker wrote:

Dump C# today Wink [;)]

Oh No... A lotta people are gonna hate you.  Stick out tongue [:P]

Maung Maung

Maung Maung
Top 10 Contributor
Posts 865
 MaungMaung wrote:

Oh No... A lotta people are gonna hate you.  Stick out tongue [:P]

Thats ok. 3 million people are going to love me Wink [;)]

~Softwaremaker (BLOG) M. Twain: "I didn't have time to write a short letter, so I wrote a long one instead"

Top 25 Contributor
Posts 232
 Softwaremaker wrote:

Thats ok. 3 million people are going to love me Wink [;)]

ER! most C# people can read and write VB.NET code, I'm one of them. Why can't you guys learn C#?

Top 25 Contributor
Posts 442
 Thanh wrote:
 Softwaremaker wrote:

Thats ok. 3 million people are going to love me Wink [;)]

ER! most C# people can read and write VB.NET code, I'm one of them. Why can't you guys learn C#?

What makes you think that VB.NET programmers can't read and write C# code? Stick out tongue [:P]

I am one of the VB.NET guy who can also read and write C# code.Wink [;)]

Cheers,

Maung Maung

Maung Maung
Top 10 Contributor
Posts 865

 Thanh wrote:
Why can't you guys learn C#?

Hahaha. But I do write C#. Wink [;)]

Ignore me: I am just a sh**-disturber sometimes Stick out tongue [:P]

~Softwaremaker (BLOG) M. Twain: "I didn't have time to write a short letter, so I wrote a long one instead"

Top 10 Contributor
Posts 1,125

For ppl like us, VB.NET and C# differs in the same way as it potato differs in American and English accent...

Looking and VB.NET and C# code everyday, I forgot the difference between the two already... Tongue Tied [:S]

Blog -> http://www.dotnetjunkies.com/weblog/rohanthomas/ Singapore's Professional .NET User Group Rocks!!!! Yes
Top 10 Contributor
Posts 1,626
 Softwaremaker wrote:

Ignore me: I am just a sh**-disturber sometimes Stick out tongue [:P]

Let's ban him. Stick out tongue [:P]

Software development made easy with Paladin RAD Framework. Save some trees, use Stickies.NET
Top 10 Contributor
Posts 2,284
 xtreme.net wrote:
Looking and VB.NET and C# code everyday, I forgot the difference between the two already...
The difference? Consider a very simple logic to take in two numbers and compare them. Witness the resulting IL from the different compilers.

C#
.namespace CompareNumbersCSharp
{
  .class private auto ansi beforefieldinit Class1
         extends [mscorlib]System.Object
  {
    .method private hidebysig static void
            Main(string[] args) cil managed
    {
      .entrypoint
      .custom instance void [mscorlib]System.STAThreadAttribute::.ctor() = ( 01 00 00 00 )
      // Code size       68 (0x44)
      .maxstack  2
      .locals init (int32 V_0,
               int32 V_1)

      IL_0000:  ldstr      "Enter first number: "
      IL_0005:  call       void [mscorlib]System.Console::Write(string)
      IL_000a:  call       string [mscorlib]System.Console::ReadLine()
      IL_000f:  call       int32 [mscorlib]System.Int32::Parse(string)
      IL_0014:  stloc.0
      IL_0015:  ldstr      "Enter second number: "
      IL_001a:  call       void [mscorlib]System.Console::Write(string)
      IL_001f:  call       string [mscorlib]System.Console::ReadLine()
      IL_0024:  call       int32 [mscorlib]System.Int32::Parse(string)
      IL_0029:  stloc.1
      IL_002a:  ldloc.0
      IL_002b:  ldloc.1
      IL_002c:  bgt.s      IL_0039

      IL_002e:  ldstr      "First number lesser or equal."
      IL_0033:  call       void [mscorlib]System.Console::WriteLine(string)
      IL_0038:  ret

      IL_0039:  ldstr      "Second number greater."
      IL_003e:  call       void [mscorlib]System.Console::WriteLine(string)
      IL_0043:  ret
    } // end of method Class1::Main


VB
.namespace CompareNumbersVB
{
  .class private auto ansi sealed Module1
         extends [mscorlib]System.Object
  {
    .custom instance void [Microsoft.VisualBasic]Microsoft.VisualBasic.CompilerServices.StandardModuleAttribute::.ctor() = ( 01 00 00 00 )
    .method public static void  Main() cil managed
    {
      .entrypoint
      .custom instance void [mscorlib]System.STAThreadAttribute::.ctor() = ( 01 00 00 00 )
      // Code size       86 (0x56)
      .maxstack  3
      .locals init (object V_0,
               object V_1)

      IL_0000:  ldstr      "Enter first number: "
      IL_0005:  call       void [mscorlib]System.Console::Write(string)
      IL_000a:  call       string [mscorlib]System.Console::ReadLine()
      IL_000f:  call       int32 [mscorlib]System.Int32::Parse(string)
      IL_0014:  box        [mscorlib]System.Int32
      IL_0019:  stloc.0

      IL_001a:  ldstr      "Enter second number: "
      IL_001f:  call       void [mscorlib]System.Console::Write(string)
      IL_0024:  call       string [mscorlib]System.Console::ReadLine()
      IL_0029:  call       int32 [mscorlib]System.Int32::Parse(string)
      IL_002e:  box        [mscorlib]System.Int32
      IL_0033:  stloc.1

      IL_0034:  ldloc.0
      IL_0035:  ldloc.1
      IL_0036:  ldc.i4.0
      IL_0037:  call       int32 [Microsoft.VisualBasic]Microsoft.VisualBasic.CompilerServices.ObjectType::ObjTst(object,
                                                                                                                  object,
                                                                                                                  bool)
      IL_003c:  ldc.i4.0

      IL_003d:  bgt.s      IL_004b

      IL_003f:  ldstr      "First number lesser or equal."
      IL_0044:  call       void [mscorlib]System.Console::WriteLine(string)
      IL_0049:  br.s       IL_0055

      IL_004b:  ldstr      "Second number greater."
      IL_0050:  call       void [mscorlib]System.Console::WriteLine(string)
      IL_0055:  ret
    } // end of method Module1::Main

  } // end of class Module1


Anybody care to explain why the VB compiler, for such a simple operation, likes to box the int32 into an object reference rather than just referring to the primitive type itself?

The melody of logic will always play out the truth. ~ Narumi Ayumu, Spiral

Top 10 Contributor
Posts 1,125

 icelava wrote:
Anybody care to explain why the VB compiler, for such a simple operation, likes to box the int32 into an object reference rather than just referring to the primitive type itself?

Erm... Cause its not good as C#? Angel [A]

Sorry I'm just playing...

and creating noise in the forum... looks like i've gotta delete this post Super Angry [8o|]

Blog -> http://www.dotnetjunkies.com/weblog/rohanthomas/ Singapore's Professional .NET User Group Rocks!!!! Yes
Top 10 Contributor
Posts 884

 icelava wrote:

Anybody care to explain why the VB compiler, for such a simple operation, likes to box the int32 into an object reference rather than just referring to the primitive type itself?

how did you declare the variables to store the first number and second number?

Top 25 Contributor
Posts 232
 MaungMaung wrote:
 Thanh wrote:
 Softwaremaker wrote:

Thats ok. 3 million people are going to love me Wink [;)]

ER! most C# people can read and write VB.NET code, I'm one of them. Why can't you guys learn C#?

What makes you think that VB.NET programmers can't read and write C# code? Stick out tongue [:P]

I am one of the VB.NET guy who can also read and write C# code.Wink [;)]

Cheers,

Maung Maung

Ah, I never assume that VB.NET programers can't read and write C# code. Would that go against my profession because I used to write VB code myself? I just point out to those who don't like C# and never want to learn it. To me, they are both the same family and it's always good to at least understand the other. I have to sometimes read Java code and its design and architecture which I find extremely useful in the opposite world. The more language we know, the better there is.

 

Top 10 Contributor
Posts 865

There are many ways to emit out the same exact IL with VB.NET as well as C#. It is just that VB.NET carries a lot of legacy weight with it and it has to appeal for the VB6 folks to move forward, thats why there are some idiosyncrancies to deal with.

If VB.NET could start on the same footing as C#, this legacy would all disappear

~Softwaremaker (BLOG) M. Twain: "I didn't have time to write a short letter, so I wrote a long one instead"

Top 10 Contributor
Posts 2,284
 weehyong wrote:
how did you declare the variables to store the first number and second number?
VBC#
        Console.Write("Enter first number: ")
        Dim first = Integer.Parse(Console.ReadLine())
        Console.Write("Enter second number: ")
        Dim second = Integer.Parse(Console.ReadLine())

        If (first <= second) Then
            Console.WriteLine("First number lesser or equal.")
        Else
            Console.WriteLine("Second number greater.")
        End If
            Console.Write("Enter first number: ");
            int first = int.Parse(Console.ReadLine());
            Console.Write("Enter second number: ");
            int second = int.Parse(Console.ReadLine());

            if (first <= second)
                Console.WriteLine("First number lesser or equal.");
            else
                Console.WriteLine("Second number greater.");

The melody of logic will always play out the truth. ~ Narumi Ayumu, Spiral

Top 25 Contributor
Posts 176
Just want to make some wild guess, does option strict/explicit have any impact on the IL?
Also, in VB, does Integer, Int16, Int32 make any difference?
How about this.... run the Reflector on the compiled C# and see what is the VB.NET equivalent.
my development sketch book my personal blog
Page 1 of 2 (17 items) 1 2 Next > | RSS
Copyright SgDotNet 2004-2008
Powered by Community Server (Commercial Edition), by Telligent Systems