Valhalla Legends Archive

Programming => General Programming => .NET Platform => Topic started by: bRoKeN on February 21, 2004, 07:49 PM

Title: Visual Basic . NET
Post by: bRoKeN on February 21, 2004, 07:49 PM
Okay, well i was going to start by learning Visual Basic and i went to the book store and baught a book but it seems to teach Visual Basic . NET. I just wanted to know is VB and VB.NEt = same thing or like if i learn VB.NET i can work with VB also? And what's the diffecrence.
Title: Re:Visual Basic . NET
Post by: hismajesty on February 22, 2004, 06:14 AM
They are very different in my opinion.
Title: Re:Visual Basic . NET
Post by: bRoKeN on February 22, 2004, 08:43 AM
I was told its more advanced, For advanced programming.
Title: Re:Visual Basic . NET
Post by: Dark-Feanor on February 23, 2004, 11:28 AM
Visual Basic .NET is basically a more object oriented version of Visual Basic 6. If you know one of them, you could probably program in the other without really having to learn anything new.
Title: Re:Visual Basic . NET
Post by: MyndFyre on February 23, 2004, 05:25 PM
Quote from: DaRk-FeAnOr on February 23, 2004, 11:28 AM
Visual Basic .NET is basically a more object oriented version of Visual Basic 6. If you know one of them, you could probably program in the other without really having to learn anything new.

This is correct.  As a matter of fact, it's quite easy to learn VB 6 once knowing a .NET language (I went from JavaScript to JScript.NET to C# to VB .NET to VB 6).
Title: Re:Visual Basic . NET
Post by: Adron on February 23, 2004, 05:33 PM
Quote from: Myndfyre on February 23, 2004, 05:25 PM
This is correct.  As a matter of fact, it's quite easy to learn VB 6 once knowing a .NET language (I went from JavaScript to JScript.NET to C# to VB .NET to VB 6).

Are you generally backwards? :P
Title: Re:Visual Basic . NET
Post by: K on February 23, 2004, 05:39 PM
Quote from: Myndfyre on February 23, 2004, 05:25 PM
Quote from: DaRk-FeAnOr on February 23, 2004, 11:28 AM
Visual Basic .NET is basically a more object oriented version of Visual Basic 6. If you know one of them, you could probably program in the other without really having to learn anything new.

This is correct.  As a matter of fact, it's quite easy to learn VB 6 once knowing a .NET language (I went from JavaScript to JScript.NET to C# to VB .NET to VB 6).

I will stick to the stance that going from VB6 to a .NET is more difficult.  You are more likely to use legacy functions from the Microsoft.VisualBasic namespace than the more object oriented System.* namespaces - for example Open / Print / Close for file IO instead of using a System.IO.Filestream, InStr() instead of String.IndexOf(), Mid$() instead of String.Substring().  You get the picture.  VB.NET lets you do a lot of things not standard to the CLR in the name of compatability (globule modules ...)

Sure, youre code will work, but it's kind of like writing C code in C++.  
Title: Re:Visual Basic . NET
Post by: Grok on February 23, 2004, 05:48 PM
In my VB.NET and ASP.NET projects, I still write code with VB6 keywords, methods, properties.  It will take more time and experience to write VB.NET the way it was intended.
Title: Re:Visual Basic . NET
Post by: Adron on February 23, 2004, 06:06 PM
Quote from: K on February 23, 2004, 05:39 PM
Sure, youre code will work, but it's kind of like writing C code in C++.  

I use strcpy, memcpy & co a lot in C++ code actually. And besides, Mid is shorter than Substring and InStr is shorter than IndexOf, so they're more efficient to use.
Title: Re:Visual Basic . NET
Post by: K on February 23, 2004, 06:57 PM
Quote from: Grok on February 23, 2004, 05:48 PM
In my VB.NET and ASP.NET projects, I still write code with VB6 keywords, methods, properties.  It will take more time and experience to write VB.NET the way it was intended.

Exactly what I'm saying.

Quote from: Adron on February 23, 2004, 06:06 PM
Quote from: K on February 23, 2004, 05:39 PM
Sure, youre code will work, but it's kind of like writing C code in C++.  

I use strcpy, memcpy & co a lot in C++ code actually. And besides, Mid is shorter than Substring and InStr is shorter than IndexOf, so they're more efficient to use.

Ok, so maybe my analogy was flawed  ::)
Do you write code like this in C++ projects?
void rbtree_init(Node* root);
void rbtree_destroy(Node* root);
void rbtree_fixup(Node* x);
Node* rbtree_find(int key);
void rbtree_insert(int key);


Title: Re:Visual Basic . NET
Post by: Adron on February 24, 2004, 04:38 PM
Hmm, no, I'd probably use a class for that particular case. But I do use printf type functions in C++. Another example of using "legacy" functions...
Title: Re:Visual Basic . NET
Post by: quasi-modo on February 24, 2004, 07:00 PM
VB6 and vb.net are very similar the majority of the time syntax wise. But vb.net offers a butt load more power then vb6 when you get into the meat of it. I went striaght from vb6 to vb.net with ease. I have been using asp.net for about a year and find vb.net much easier to use then vb6. When you say vb.net is much more object oritned then vb6 it is an under statement, vb.net is completly object oriented, where as it would almost be a joke to call vb6 the least bit object oriented.
Title: Re:Visual Basic . NET
Post by: Dark-Feanor on February 24, 2004, 07:31 PM
Quote from: K on February 23, 2004, 05:39 PM
I will stick to the stance that going from VB6 to a .NET is more difficult.  
Not if you already understand OO programming.
Title: Re:Visual Basic . NET
Post by: quasi-modo on February 24, 2004, 07:54 PM
Quote from: DaRk-FeAnOr on February 24, 2004, 07:31 PM
Quote from: K on February 23, 2004, 05:39 PM
I will stick to the stance that going from VB6 to a .NET is more difficult.  
Not if you already understand OO programming.
yes you can do everything in vb.net you can do in vb6 with the same or greater ease. You do not even need to fully understand OO to use vb.net, but eventually it will come in handy.
Title: Re:Visual Basic . NET
Post by: MyndFyre on February 26, 2004, 10:18 PM
Quote from: Adron on February 23, 2004, 05:33 PM
Quote from: Myndfyre on February 23, 2004, 05:25 PM
This is correct.  As a matter of fact, it's quite easy to learn VB 6 once knowing a .NET language (I went from JavaScript to JScript.NET to C# to VB .NET to VB 6).

Are you generally backwards? :P

hehe, no.  I learned JavaScript first because it is a client-side web language.  Then I went to JScript.NET when I got into server-side junk.  C# was being touted by Microsoft for the .NET platform so I picked that up, and once I had that, VB .NET was a breeze.  Having been looking at code samples, all the other VB-centric stuff (such as vbCrLf and vbRed, all that fun junk) was easy to pick up for VB6.  :p
Title: Re:Visual Basic . NET
Post by: Grok on March 02, 2004, 05:04 PM
VB.NET makes such prettier code than VB6.


               'see if document has correct properties
               Dim kfDoc As AKO32.CDocument = New AKO32.CDocument
               kfDoc.hKGI = KGI
               kfDoc.OpenDocument(Doc.docid)
               Dim result As Integer = 0
               result = IIf(Len(Doc.title) = 0, 0, Math.Abs([String].Compare(Doc.title, kfDoc.Title)))
               result += IIf(Len(Doc.person) = 0, 0, Math.Abs([String].Compare(Doc.person, kfDoc.Person)))
               result += IIf(Len(Doc.type) = 0, 0, Math.Abs([String].Compare(Doc.type, kfDoc.UserType)))
               result += IIf(Len(Doc.kfdate) = 0, 0, Math.Abs([String].Compare(Doc.kfdate, kfDoc.DateCreated)))
               result += IIf(Len(Doc.description) = 0, 0, Math.Abs([String].Compare(Doc.description, kfDoc.Description)))
               result += IIf(Len(Doc.kfgroup) = 0, 0, Math.Abs([String].Compare(Doc.kfgroup, kfDoc.Group)))
               result += IIf(Len(Doc.subclass) = 0, 0, Math.Abs([String].Compare(Doc.subclass, kfDoc.Subclass)))
               If result = 0 Then      'so far so good, check keywords
                   Dim kw() As String = Split(kfDoc.UserKeywords, vbCrLf)
                   Dim lPos As Integer
                   For lPos = 1 To UBound(kw) + 1
                       Select Case lPos
                           Case 1 : result += IIf(Len(Doc.keywords1) = 0, 0, Math.Abs([String].Compare(Doc.keywords1, kw(lPos - 1))))
                           Case 2 : result += IIf(Len(Doc.keywords2) = 0, 0, Math.Abs([String].Compare(Doc.keywords2, kw(lPos - 1))))
                           Case 3 : result += IIf(Len(Doc.keywords3) = 0, 0, Math.Abs([String].Compare(Doc.keywords3, kw(lPos - 1))))
                           Case 4 : result += IIf(Len(Doc.keywords4) = 0, 0, Math.Abs([String].Compare(Doc.keywords4, kw(lPos - 1))))
                           Case 5 : result += IIf(Len(Doc.keywords5) = 0, 0, Math.Abs([String].Compare(Doc.keywords5, kw(lPos - 1))))
                           Case 6 : result += IIf(Len(Doc.keywords6) = 0, 0, Math.Abs([String].Compare(Doc.keywords6, kw(lPos - 1))))
                           Case 7 : result += IIf(Len(Doc.keywords7) = 0, 0, Math.Abs([String].Compare(Doc.keywords7, kw(lPos - 1))))
                           Case 8 : result += IIf(Len(Doc.keywords8) = 0, 0, Math.Abs([String].Compare(Doc.keywords8, kw(lPos - 1))))
                           Case 9 : result += IIf(Len(Doc.keywords9) = 0, 0, Math.Abs([String].Compare(Doc.keywords9, kw(lPos - 1))))
                       End Select
                   Next lPos
               End If

               'see if docid is contained in destination container id
               result += IIf(KGI.IsContainedIn(Doc.docid, Doc.destid), 0, 1)

               If result = 0 Then
                   'all is well, update status ...
Title: Re:Visual Basic . NET
Post by: quasi-modo on March 04, 2004, 04:58 PM
Quote from: Grok on March 02, 2004, 05:04 PM
VB.NET makes such prettier code than VB6.
I aggree. Its the little things that have evolved in the syntax that make the codeing so much easier.
Title: Re:Visual Basic . NET
Post by: Adron on March 04, 2004, 05:52 PM
Did they fix the IIf operator to only evaluate one of the expressions, and did they fix boolean logic to be short-circuited?
Title: Re:Visual Basic . NET
Post by: Banana fanna fo fanna on March 04, 2004, 06:02 PM
Quote from: peofeoknight on March 04, 2004, 04:58 PM
Quote from: Grok on March 02, 2004, 05:04 PM
VB.NET makes such prettier code than VB6.
I aggree. Its the little things that have evolved in the syntax that make the codeing so much easier.
I think he was being sarcastic.
Title: Re:Visual Basic . NET
Post by: Grok on March 04, 2004, 06:06 PM
Still ewwy.

QuoteAs part of preparing the argument list for the call to IIf, the Visual Basic compiler calls every function in every expression.
Title: Re:Visual Basic . NET
Post by: Adron on March 04, 2004, 08:12 PM
And what about boolean logic?
Title: Re:Visual Basic . NET
Post by: quasi-modo on March 04, 2004, 10:53 PM
Quote from: St0rm.iD on March 04, 2004, 06:02 PM
Quote from: peofeoknight on March 04, 2004, 04:58 PM
Quote from: Grok on March 02, 2004, 05:04 PM
VB.NET makes such prettier code than VB6.
I aggree. Its the little things that have evolved in the syntax that make the codeing so much easier.
I think he was being sarcastic.
But I wasn't  :P
Title: Re:Visual Basic . NET
Post by: Grok on March 05, 2004, 06:00 AM
Quote from: Adron on March 04, 2004, 08:12 PM
And what about boolean logic?

I don't know of an obvious way to test that.  Maybe

x = 0 and (side_effect_function(z))

and see if the side effect happens?
Title: Re:Visual Basic . NET
Post by: Adron on March 05, 2004, 11:50 AM
Quote from: Grok on March 05, 2004, 06:00 AM
I don't know of an obvious way to test that.  Maybe

x = 0 and (side_effect_function(z))

and see if the side effect happens?

A typical example of when I'd want it to be short-circuited is for testing fields of a recordset like this:


If Not IsNull(rs!field) And rs!field = "something" Then


If it is short-circuited, rs!field = "something" won't be evaluated, and you won't get a run-time error.

Another example is:


If y <> 0 And x/y > 12 Then

Title: Re:Visual Basic . NET
Post by: MyndFyre on March 22, 2004, 12:29 AM
Looks like Adron's been left hanging here...

.NET evaluates boolean expressions the same way across all languages.

Your example



If x = 0 And SideEffectFunction(z)



would not call SideEffectFunction() if x was not 0.

The example


If Not IsNull(rs!field) And rs!field = "something" Then


would not use the comparison of rs!field to "something" if the first condition failed.

Cheers.
Title: Re:Visual Basic . NET
Post by: Adron on March 22, 2004, 04:29 AM
Ah, neat!

That's something that has annoyed me for a long time in VB.
Title: Re:Visual Basic . NET
Post by: quasi-modo on March 22, 2004, 04:13 PM
its just like any other language in any other scripting I mean if the first part of an and is false the comp just stops right there. Its the same in c++, the same in c, the same in java.
Title: Re:Visual Basic . NET
Post by: Adron on March 22, 2004, 04:18 PM
Quote from: peofeoknight on March 22, 2004, 04:13 PM
its just like any other language in any other scripting I mean if the first part of an and is false the comp just stops right there. Its the same in c++, the same in c, the same in java.

But different in VB.
Title: Re:Visual Basic . NET
Post by: quasi-modo on March 22, 2004, 04:19 PM
I dont know about vb6... but vb.net is just like the other scripting languages.
Title: Re:Visual Basic . NET
Post by: MyndFyre on March 22, 2004, 04:46 PM
Quote from: peofeoknight on March 22, 2004, 04:19 PM
I dont know about vb6... but vb.net is just like the other scripting languages.

uhh, no.  VB .NET is not even a scripting language!  You might be thinking of VBA (Visual Basic for Applications) or VBScript, but Visual Basic .NET is not a scripting language.

Its late binding features allow it to be used in a scripting environment, such as the dead-and-nearly-forgotten Visual Studio for Applications (Microsoft.Vsa namespace), but even that code is compiled, not interpreted.
Title: Re:Visual Basic . NET
Post by: quasi-modo on March 22, 2004, 05:10 PM
would you consider vb to be a scripting language then? vb.net can be used to make executable programs. I would consider php to be a scripting language though it is only use to make dynamic web sites.
Title: Re:Visual Basic . NET
Post by: MyndFyre on March 22, 2004, 06:13 PM
Quote from: peofeoknight on March 22, 2004, 05:10 PM
would you consider vb to be a scripting language then? vb.net can be used to make executable programs. I would consider php to be a scripting language though it is only use to make dynamic web sites.

No.  Visual Basic is a compiled language; VBScript (Visual Basic Scripting Edition) is an interpreted language.  Visual Basic .NET is a compiled language; PHP is an interpreted language.

JavaScript/JScript is an interpreted language.  JScript .NET is a compiled language.  Despite its name, JScript .NET is no longer a scripting language; by Microsoft's own statements, it no longer is a scripting language, but rather a full object-oriented language with a "scripting feel."
Title: Re:Visual Basic . NET
Post by: quasi-modo on March 22, 2004, 07:43 PM
so java could be either or depending on how it is used?