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 2MQ6
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 dblRate variable’s value in the lblRate.Text property. The value should contain a percent sign and no decimal places.
Write an expression that multiplies the value stored in the dblTotal variable by 15%.
Write a statement that displays the intQuantity variable’s value in the lblQuantity.Text property.
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
- Which property allows you to specify a specific character that will always be displayed in a text box, no matter what character the user types? a. Char b. CharPassword c. Password d. PasswordChararrow_forwardCreate a statement that shows the value of the letterGrade char variable in a message box.arrow_forwardIf the txtGrossPay control contains the number 1234.78, what number will theInteger.TryParse(txtGrossPay.Text, intGross) statement assign to theintGross variable?arrow_forward
- Write an assignment statement that concatenates the message “She lives in ” with the contents of the strCity variable, and then assigns the result to the lblCity control.arrow_forwardThe item that appears in the text portion of a combo box is stored in which property? a. SelectedText b. SelectedValue c. Text d. TextItemarrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning