Visual Basic Tutorial - 44 - ByVal

Поділитися
Вставка
  • Опубліковано 25 січ 2025
  • Source Code: github.com/the...
    Core Deployment Guide (AWS): docs.google.co...

КОМЕНТАРІ • 37

  • @alphaahtube
    @alphaahtube 12 років тому

    That depends on what the function does. A function could need a string to output, or to manipulate, but it would return an integer.
    An example is a function that gets the length of a string, you would pass a string as an argument, but it would return an integer.

  • @alphaahtube
    @alphaahtube 12 років тому

    He means that, you can pass arguments of any type even if it's different than the function's type. Function's type is the type of data that it returns, argument's type is the type of argument that is passed to the function.

  • @xXBR4D3NXx
    @xXBR4D3NXx 11 років тому +1

    ByVal - "
    Specifies that an argument is passed in such a way that the called procedure or property cannot change the value of a variable underlying the argument in the calling code." - MSDN

  • @floreloriz4667
    @floreloriz4667 9 років тому

    I didn't know so simple calculator can be made. TY

  • @OriginalTrousers
    @OriginalTrousers 11 років тому +1

    Why use ByVal at all? Why not just do
    private function subtract(num1 as double, num2 as double) as double
    return num1 - num2
    end function

  • @rajamohdafiq480
    @rajamohdafiq480 11 років тому

    this is tutorial so that someone like me can learn the basic thing that maybe can be use in big thing.

  • @xiaozhang4066
    @xiaozhang4066 11 років тому

    I still don't understand what ByVal does. Does is dim the variables outside the function? Cause you didn't dim num1 and num2 in sub but function. Also, the perimeter (TextBox1.text, TextBox2.text) confuses me allot.

  • @pb695
    @pb695 11 років тому

    what if i want characters e.g "a,g,h," instead of numbers as the variable?

    • @MrEpicSpace
      @MrEpicSpace 10 років тому

      instead change it is "As String"

  • @2pimpinout
    @2pimpinout 13 років тому

    @techstuffs27 double click on "My Project" on the side, and a Windows will open with an Application tab selected. You will find the icon selection.

  • @longsophy1130
    @longsophy1130 8 років тому

    Could anybody tell me if textbox.text return number value or string?
    if it return a string, why we can pass this string to the arguments of double datatype in subtractNumbers function?
    sorry my English isn't good. i'm learning it.

    • @elmik1351
      @elmik1351 3 роки тому +1

      Sorry for the 5 year late reply, Textbox.text returns any value depending on the variable you want to display in the textbox.
      So, if you want to display a string in the textbox, thats fine. Works with an Integer as well as doubles.

  • @brandondupuis8243
    @brandondupuis8243 10 років тому

    Good tutorial man! Nice job :)

  • @TheRoxas13th
    @TheRoxas13th 11 років тому +2

    Yeah, it work exactly the same without the ByVal. Someone explain this to me =="

  • @ThatsoCliche
    @ThatsoCliche 12 років тому

    Private Function Divide(ByVal num1 As Double, ByVal num2 As Double)
    Return num1 / num2
    End Function
    Private Function Multiply(ByVal num1 As Double, ByVal num2 As Double)
    Return num1 * num2
    End Function
    Private Function Subtract(ByVal num1 As Double, ByVal num2 As Double)
    Return num1 - num2
    End Function
    End Class

  • @vamsikrishnanmysore2788
    @vamsikrishnanmysore2788 9 років тому

    great work....................bro

  • @rwbangsil
    @rwbangsil 9 років тому +1

    it is a bad example of byval, coz when i tried to change it to byref, it gave the same result.

    • @etherealvox2010
      @etherealvox2010 8 років тому

      assume variable "input"=10
      assume a function named "newFunction" that increments the argument
      1) using myVar i.e. newFunction(myVar x as integer) bla bla --> x +=1
      newFunction(input) the result will be 11
      console.writeline(input) the result will pe 10
      2) using myRef i.e. newFunction(myRef x as integer) bla bla --> x +=1
      newFunction(input) the result will be 11
      console.writeline(input) the result will pe 11

  • @Cliffardo
    @Cliffardo 7 років тому

    Stranger error, but its an annoying one I did this perfectly fine and I had no errors it works. I re open the project the code still works however some of it is underlined in red?
    EDIT: Okay this is happening on like everything now, even on things like Console.ReadLine it keeps underlining them in red when its fine and it is working OK I don't know what has happened but it is extremely annoying. I need to do screenshots for evidence but I can't with this there and there is nothing wrong with the code. The thing the error keeps saying is "Option Strict On disallows implicit conversions from String to Integer" This error has never come up for me before until the past hour or so I don't know if I have turned on a setting somewhere or what

  • @peterkandiwo7806
    @peterkandiwo7806 10 років тому

    it is pretty good

  • @kuroodo_
    @kuroodo_ 11 років тому +3

    MessageBox.Show("It's also a good idea to try doing things on your own without the tutorials. I've learned alot as well without watching the tutorials", "My Comment",MessageBoxButtons.OK)

  • @MrEpicSpace
    @MrEpicSpace 10 років тому +1

    ByVal isn't even needed in VB 2013, and I have done outcome comparisons and nothing changes. It's useless, and Microsoft kept ByVal there. It must change something that we know nothing about. Or maybe it really doesn't do anything Edit:It's official: ByVal is rendered useless in Visual Basic on Visual Studio 2013

    • @SCIFIDW
      @SCIFIDW 9 років тому

      ***** Sorry if this is a stupid question but I'm very new to programming.
      So you mean we can remove ByVal and it would work without replacing it with something?

    • @MrEpicSpace
      @MrEpicSpace 9 років тому

      SCIFIDW Yes. ByVal is useless in the new VB

  • @sbasalan
    @sbasalan 12 років тому

    like a couple numbers of your video style.. You made the some showing same way to show..

  • @DaCurse0
    @DaCurse0 9 років тому

    ty somuch ur op

  • @ThatsoCliche
    @ThatsoCliche 12 років тому

    Public Class Form1
    Private Sub BtnSubtract_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSubtract.Click
    Dim Answer As Double = Subtract(TextBox1.Text, TextBox2.Text)
    MessageBox.Show(Answer)
    End Sub

  • @ThatsoCliche
    @ThatsoCliche 12 років тому

    SIMPLE CALCULATOR ENJOY :D

  • @alphaahtube
    @alphaahtube 12 років тому

    C++.

  • @bomer890
    @bomer890 13 років тому

    10th to caomment...
    "where beginner javascript tutorial?"

  • @Raw2v07
    @Raw2v07 12 років тому

    @fillecool2
    Think its
    My.computer.audio.Xxxxxxxxxx
    Cant remember the rest soz intellisense will know though

  • @Quan-mh3lc
    @Quan-mh3lc 10 років тому

    hehe

  • @djuroue1
    @djuroue1 13 років тому

    5th yes yes

  • @mattwhitfield314
    @mattwhitfield314 13 років тому

    8th comment! Lol