tailieunhanh - Accelerated VB 2005 phần 6

Sự xác định định dạng mà chúng tôi đã chọn là "C" để hiển thị các số trong một định dạng tiền tệ. Đối với màn hình hiển thị đầu tiên, bạn sử dụng các ví dụ CultureInfo thuộc các chủ đề hiện tại. Đối với hai sau đây, bạn tạo một CultureInfo cho cả Đức và Nga. | 192 CHAPTER 10 WORKING WITH STRINGS Note In order to build the previous example you ll need to add a reference to the assembly located in the Framework directory. This example displays the strings using the MessageBox type defined in since the console isn t good at displaying Unicode characters. The format specifier that we ve chosen is C to display the number in a currency format. For the first display you use the CultureInfo instance attached to the current thread. For the following two you create a CultureInfo for both Germany and Russia. Note that in forming the string the type has used the CurrencyDecimalSeparator CurrencyDecimalDigits and CurrencySymbol properties of the NumberFormatInfo instance returned from the method. Had you displayed a DateTime instance then the DateTime implementation of would have utilized an instance of DateTimeFormatInfo returned from the in a similar way. and Throughout this book you ve seen used in the examples. One of the forms of WriteLine that is useful and identical to some overloads of allows you to build a composite string by replacing format tags within a string with a variable number of parameters passed in. Let s look at a quick example of string format usage Imports System Imports Imports Public Class EntryPoint Shared Sub Main ByVal args As String If 3 Then Please provide 3 parameters Return End If Dim composite As String _ 0 1 and 2 . args 0 args 1 args 2 composite End Sub End Class Here are the results from the previous example Jack Jill and Spot. CHAPTER 10 WORKING WITH STRINGS 193 You can see that a placeholder is delimited by braces and that the number within it is the zero-based index to the following .

TỪ KHÓA LIÊN QUAN