Click here to Skip to main content
15,895,142 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Subclass a Control by UserControl Pin
Dave Kreskowiak27-May-09 7:10
mveDave Kreskowiak27-May-09 7:10 
GeneralRe: Subclass a Control by UserControl Pin
Samir Ibrahim27-May-09 21:36
Samir Ibrahim27-May-09 21:36 
GeneralRe: Subclass a Control by UserControl Pin
Dave Kreskowiak28-May-09 2:19
mveDave Kreskowiak28-May-09 2:19 
GeneralRe: Subclass a Control by UserControl Pin
Samir Ibrahim28-May-09 3:46
Samir Ibrahim28-May-09 3:46 
GeneralRe: Subclass a Control by UserControl Pin
Nagy Vilmos28-May-09 3:56
professionalNagy Vilmos28-May-09 3:56 
GeneralRe: Subclass a Control by UserControl Pin
Samir Ibrahim28-May-09 4:19
Samir Ibrahim28-May-09 4:19 
GeneralRe: Subclass a Control by UserControl Pin
Nagy Vilmos28-May-09 4:35
professionalNagy Vilmos28-May-09 4:35 
GeneralRe: Subclass a Control by UserControl Pin
Dave Kreskowiak28-May-09 5:38
mveDave Kreskowiak28-May-09 5:38 
Public Class myclass1
    ' It's "best practice" to explicitly declare visibility of the Function and to
    ' define it's return type if you're not using LINQ, or some other technology
    ' that will try to imply the return type for you based on possible values that
    ' the code might return.
    Public Function Sum() As Integer
        ' You haven't defined Sum anywhere, except as a function name.  VB6 supported just
        ' treating the function name as the return value holder.  You should NOT be using
        ' practice in VB.NET.  It is only there for backward compatibility with converted
        ' VB6 code.
        Sum = 1 + 2  ' <-- Works Fine
 
        ' Now you're treating Sum not as a variable, as in the previous line, but as an object
        ' or property.  This will not work since Sum, outside of it's own code, cannot be
        ' as a variable since, in true OOP, it's a method name.
        Me.Sum = 1 + 2  ' <-- Gives error although me.Sum should be the same as Sum alone

        ' It is considered "best practice" to explicitly declare a single Return statement.
        Return x
     End Function
End Class

Serisouly, VB6 and VFP have taught you some very bad habits that are not supported in the true OOP world of VB.NET. I still highly recommend picking up a book on VB.NET so you can learn how the basics are really supposed to work, instead of the garbage VFP taught you.


A guide to posting questions on CodeProject[^]



Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic
     2006, 2007, 2008




GeneralRe: Subclass a Control by UserControl Pin
Dave Kreskowiak28-May-09 4:21
mveDave Kreskowiak28-May-09 4:21 
GeneralRe: Subclass a Control by UserControl Pin
Trollslayer28-May-09 3:03
mentorTrollslayer28-May-09 3:03 
GeneralRe: Subclass a Control by UserControl Pin
Nagy Vilmos28-May-09 3:20
professionalNagy Vilmos28-May-09 3:20 
GeneralRe: Subclass a Control by UserControl Pin
Samir Ibrahim28-May-09 3:58
Samir Ibrahim28-May-09 3:58 
GeneralRe: Subclass a Control by UserControl Pin
EliottA28-May-09 5:32
EliottA28-May-09 5:32 
GeneralRe: Subclass a Control by UserControl Pin
Nagy Vilmos28-May-09 5:34
professionalNagy Vilmos28-May-09 5:34 
GeneralRe: Subclass a Control by UserControl Pin
Jerry Hammond28-May-09 3:41
Jerry Hammond28-May-09 3:41 
GeneralRe: Subclass a Control by UserControl Pin
Samir Ibrahim28-May-09 4:05
Samir Ibrahim28-May-09 4:05 
GeneralRe: Subclass a Control by UserControl Pin
#realJSOP28-May-09 4:07
mve#realJSOP28-May-09 4:07 
GeneralRe: Subclass a Control by UserControl Pin
Jon_Boy28-May-09 4:22
Jon_Boy28-May-09 4:22 
GeneralRe: Subclass a Control by UserControl PinPopular
#realJSOP28-May-09 4:32
mve#realJSOP28-May-09 4:32 
GeneralRe: Subclass a Control by UserControl Pin
Jon_Boy28-May-09 5:03
Jon_Boy28-May-09 5:03 
GeneralRe: Subclass a Control by UserControl Pin
Samir Ibrahim28-May-09 4:24
Samir Ibrahim28-May-09 4:24 
GeneralRe: Subclass a Control by UserControl Pin
#realJSOP28-May-09 4:35
mve#realJSOP28-May-09 4:35 
GeneralRe: Subclass a Control by UserControl Pin
Nagy Vilmos28-May-09 4:36
professionalNagy Vilmos28-May-09 4:36 
GeneralRe: Subclass a Control by UserControl Pin
Samir Ibrahim28-May-09 4:39
Samir Ibrahim28-May-09 4:39 
AnswerRe: Subclass a Control by UserControl Pin
Jarno Burger27-May-09 7:18
Jarno Burger27-May-09 7:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.