Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
8th Edition
ISBN: 9781337102124
Author: Diane Zak
Publisher: Cengage Learning
Question
Book Icon
Chapter 3, Problem 1MQ6
Program Plan Intro

ToString Method:

The method ToString() is used to convert the number to string. All the numeric data types use ToString() method for this conversion. This method allows the user to format the value such as specifying the decimal places and adding special characters to the string which is to be displayed.

The ToString() methods formats the copy of value present in the numeric variable and then returns the result as string value.

Syntax:

numericVariableName.ToString(formatString)

  • The numericVariableName is the variable name.
  • The parameter formatString is used to format the variable’s value.
    • The formatString string should be in the form of “Axx”.
      • “A” represents the build format specifier and “xx” specifies the precision of the digits.
      • The format specifier can be in upper case letter or lower case letter.

The following table represents the list of format specifiers available in visual basic:

Format specifierDescription
C or c (Currency)It displays the string with dollar sign and included with a thousand separators. Negative values enclosed with parentheses.
N or n (Number)It displays the string with a thousand separators but not include a dollar sign. Negative values preceded by minus sign.

F or f

(Fixed-point)

It displays the string without thousand separator and dollar sign. Negative values preceded by minus sign.
P or p (Percent)It multiplies the number by 100 and displays the result with percentage sign and negative values preceded by minus sign.

Blurred answer
Students have asked these similar questions
Write a statement that displays the decPrice variable’s value in the lblPrice.Text property. The value should contain a dollar sign and two decimal places.
Write a statement that displays the intQuantity variable’s value in the lblQuantity.Text property.
1. Create a variable called NUMBER and assign the value 9 to it 2. Create an IF statement that will print out “the number is greater than 5” IF the NUMBERis greater than 5 3. Create an ELSE statement that will print out “the number is less than 5” if the number isless than 5 4. Test the code to make sure it works. Make sure to test a number greater than 8 andless than 8 5. Copy the code into the submission box or attach the code file to your submission

Chapter 3 Solutions

Programming with Microsoft Visual Basic 2017

Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,