Programming with Microsoft Visual Basic 2017
8th Edition
ISBN: 9781337102124
Author: Diane Zak
Publisher: Cengage Learning
expand_more
expand_more
format_list_bulleted
Question
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 formatString string should be in the form of “Axx”.
The following table represents the list of format specifiers available in visual basic:
Format specifier | Description |
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. |
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents 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
Ch. 3 - Prob. 1MQ1Ch. 3 - Prob. 2MQ1Ch. 3 - Prob. 3MQ1Ch. 3 - Prob. 4MQ1Ch. 3 - Prob. 5MQ1Ch. 3 - Which of the following are valid names for...Ch. 3 - Prob. 1MQ2Ch. 3 - Prob. 2MQ2Ch. 3 - Write a Dim statement that declares a Boolean...Ch. 3 - Prob. 1MQ3
Ch. 3 - Prob. 2MQ3Ch. 3 - Prob. 3MQ3Ch. 3 - Write a TryParse method that stores the strSales...Ch. 3 - Prob. 1MQ4Ch. 3 - Prob. 2MQ4Ch. 3 - Prob. 3MQ4Ch. 3 - Prob. 4MQ4Ch. 3 - Prob. 5MQ4Ch. 3 - Prob. 1MQ5Ch. 3 - Prob. 2MQ5Ch. 3 - Prob. 3MQ5Ch. 3 - Prob. 4MQ5Ch. 3 - Prob. 1MQ6Ch. 3 - Prob. 2MQ6Ch. 3 - Prob. 3MQ6Ch. 3 - Prob. 4MQ6Ch. 3 - Prob. 5MQ6Ch. 3 - Prob. 1MQ7Ch. 3 - Prob. 2MQ7Ch. 3 - Prob. 3MQ7Ch. 3 - Prob. 4MQ7Ch. 3 - Prob. 1MQ8Ch. 3 - Prob. 2MQ8Ch. 3 - Prob. 3MQ8Ch. 3 - Prob. 4MQ8Ch. 3 - Prob. 1MQ9Ch. 3 - Prob. 2MQ9Ch. 3 - Prob. 3MQ9Ch. 3 - Prob. 1RQCh. 3 - Prob. 2RQCh. 3 - What is the result of the following expression: 96...Ch. 3 - Which of the following is an invalid name for a...Ch. 3 - The expression intNum * intNum * intNum is...Ch. 3 - What is the result of the following expression: 3...Ch. 3 - Prob. 7RQCh. 3 - Which of the following statements declares a...Ch. 3 - Which of the following can be used to clear the...Ch. 3 - Prob. 10RQCh. 3 - Which of the following declares a procedure-level...Ch. 3 - Prob. 12RQCh. 3 - Prob. 13RQCh. 3 - Prob. 14RQCh. 3 - Prob. 15RQCh. 3 - Prob. 16RQCh. 3 - A static variable has the same...Ch. 3 - Prob. 18RQCh. 3 - Which of the following statements declares a...Ch. 3 - Most of the memory locations declared in an...Ch. 3 - Prob. 1ECh. 3 - Prob. 2ECh. 3 - Prob. 3ECh. 3 - Prob. 14E
Knowledge Booster
Similar questions
- Assume certain facts. Points is the name of an int variable, and TextBox is the name of a TextBox control. Create an if-else statement that converts the Text property of the pointsTextBox control to an int and saves the result in the points variable using one of the TryParse methods. If the conversion fails, a message box will appear with an error message.arrow_forwardWrite a statement that displays the dblRate variable’s value in the lblRate.Text property. The value should contain a percent sign and no decimal places.arrow_forwardAssume pointsTextBox is the name of a TextBox control and points is the name of an int variable. Write an if-else statement that uses one of the TryParse methods to convert the pointsTextBox control’s Text property to an int and stores the result in the points variable. If the conversion is not successful, display an error message in a message box.arrow_forward
- Write an assignment statement that increments the intTotal variable by the contents of the intQuantity variable.arrow_forwardThe strItem variable contains the string “XMredBQ”. Write a statement that uses the Substring method to assign the string “red” to the strColor variable.arrow_forwardWhen an object is falling because of gravity, the following formula can be used to determine the distance the object falls in a specific time period:d =1/2 gt2The variables in the formula are as follows: d is the distance in meters, g is 9.8, and t is the amount of time in seconds that the object has been falling. Create an application that allows the user to enter the amount of time that an object has fallen and then displays the distance that the object fell. The application should have a method named FallingDistance. The FallingDistance method should accept an object’s falling time (in seconds) as an argument. The method should return the distance in meters that the object has fallen during that time interval.arrow_forward
- The dblBonus variable contains the number 1234.75. Write the assignment statement to display the value with a dollar sign, a thousands separator, and no decimal places in the lblBonus control.arrow_forwardIf the decPay variable contains the number 1200.76, which of the following statements displays the number as 1,200.76? a. lblPay.Text = decPay.ToString("N2") b. lblPay.Text = decPay.ToString("F2") c. lblPay.Text = decPay.ToString("D2") d. lblPay.Text = decPay.ToString("C2")arrow_forwardThe strTotal variable contains the string “***75.67”. Write a statement that uses the TrimStart method to change the variable’s contents to “75.67”.arrow_forward
- Using C# in a visual studio form, Create an application. Add a label and a button to the form. The button’s Click event procedure should add the number 1 to the contents of a class-level Integer variable named intNumber and then display the variable’s contents in the label. Code the application. Be sure to enter the three Option statements above the Public Class clause. Save the solution and then start and test the application. Next, change the class-level variable to a static variable.arrow_forwardWrite a programming statement that gives the focus to a TextBox control named numberTextBox.arrow_forwardplease qwe3arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,