Go to GoReading for breaking news, videos, and the latest top stories in world news, business, politics, health and pop culture.

What Is {0} in Visual Basic?

104 11

    Specifying Parameters

    • String functions such as .Write() or .String.Format() use curly braces to indicate the array index value to be passed into the function. To output the first item in the array, myListOfItems, you could use the code, "MyString.Write("The first item is {0}.", myListOfItems)".

    Initializing Arrays

    • An alternate use of curly braces in Visual Basic comes in initializing arrays when they're created. For instance, a programmer might code "Dim intNewArray() as Integer = {0}", putting zero in the first element of the array "intNewArray".

    Zero as False

    • An unconventional use of "{0}" utilizes the fact that the Visual Basic compiler considers 0 to be false. That means that a block of code could use "{0}" as a placeholder to do nothing.

Source...

Leave A Reply

Your email address will not be published.