Tech Off Thread

4 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Video learning VB. Beginner and intermediate level maintenance

Back to Forum: Tech Off
  • User profile image
    skyblack2

    Hi ...

    My question is related to VB programming language.

    Please do not close this thread.
    Excuse me if I act contrary to the rules.
    Because I do not speak English and is very difficult to find a training video VB.NET me.
    And the site is such that it is hardly possible to find a training video VB.NET.
    If you can help me to find VB.NET training video or a link to your video.
    I'm a newbie , I'm middle-level education videos

    Excuse me if I'm wrong, including
    Thank you very much

  • User profile image
    gduncan411

    Have you looked at the videos and lessons here, http://channel9.msdn.com/posts/Beginner, such as this one, http://channel9.msdn.com/Series/Visual-Basic-Development-for-Absolute-Beginners?

    Hope this helps,
    Greg

  • User profile image
    sougata12

    PublicClassCar

    PublicProperty make AsString

    PublicProperty model AsString

    PublicProperty year AsInteger

    PublicProperty colour AsString

    EndClass

    ModuleModule1

    Sub Main()

    Dim myNewCar AsNewCar

    With myNewCar

    .make = "Jaguar"

    .model = "F Type"

    .year = 2013

    .colour = "Red"

    EndWith

     

    Console.WriteLine("The original details of the car are: {0}...{1}...{2}....{3}",

    myNewCar.make, myNewCar.model, myNewCar.year, myNewCar.colour)

    Console.WriteLine("-------------------------------------------------------------")

    Console.WriteLine("")

    doByValue1(myNewCar) ' where we are creating a new instance inside the method

    Console.WriteLine("After executing doByValue1 method: {0}...{1}...{2}....{3}",

    myNewCar.make, myNewCar.model, myNewCar.year, myNewCar.colour)

    Console.WriteLine("")

    doByValue2(myNewCar) ' where we don't create any new instance inside the method

    Console.WriteLine("After executing doByValue2 method: {0}...{1}...{2}....{3}",

    myNewCar.make, myNewCar.model, myNewCar.year, myNewCar.colour)

    Console.ReadLine()

    EndSub

    Sub doByValue1(ByVal myCar AsCar)

    myCar = NewCar()

    myCar.make = "Masserati"

    Console.WriteLine("From inside the BY VAL 1 method: {0}...{1}...{2}...{3}", myCar.make,

    myCar.model, myCar.year, myCar.colour)

    Console.WriteLine("")

    EndSub

    Sub doByValue2(ByVal myCar AsCar)

    'myCar = New Car()

    myCar.make = "Masserati"

    Console.WriteLine("From inside the BY VAL 2 method: {0}...{1}...{2}...{3}", myCar.make,

    myCar.model, myCar.year, myCar.colour)

    Console.WriteLine("")

    EndSub

    EndModule

     

    In the above code the output corresponding to the dobyVal2 method (where we are not creating any new instance) is puzzling me. It is ok that the when we print the values of the different fields of myCar from within the method the updated values are being printed. But what is strange is that in this case the values are getting modified outside the method (ie in the main program also). This should not be the case as only the copy should gets modified when we pass using ByVal. Can you pls explain what's going on?

  • User profile image
    spivonious

    @sougata12: It's because you are passing the reference by value, not the entire instance.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.