Visual Basic, .NET, ASP, VBScript
 

   
   
     

Форум - Общий форум

Страница: 1 |

 

  Вопрос: Format Function Добавлено: 03.08.02 20:04  

Автор вопроса:  Zeus | Web-сайт: apirussia.by.ru | ICQ: 161801353 

Люди, помогите использовать Format Function для изменения представления формата времени!!!

Ответить

  Ответы Всего ответов: 1  

Номер ответа: 1
Автор ответа:
 paul_sn



Вопросов: 16
Ответов: 164
 Web-сайт: sergeyev.zzn.com
 Профиль | | #1
Добавлено: 03.08.02 20:16

Вот выдержка из MSDN, может разбирешься

Format Function

Returns a string formatted according to instructions contained in a format String expression.

Public Shared Function Format( _   ByVal Expression As Object, _   Optional ByVal Style As String = "" _) As String

Parameters

Expression
Required. Any valid expression.
Style
Optional. A valid named or user-defined format String expression.

Settings

For information on how to create the Style argument, see the appropriate topic listed below:

To formatDo this
NumbersUse predefined numeric formats or create user-defined numeric formats.
Dates and timesUse predefined date/time formats or create user-defined date/time formats.
Date and time serial numbersUse date and time formats or numeric formats.

If you try to format a number without specifying Style, the Format function provides functionality similar to the Str function, although it is internationally aware. However, positive numbers formatted as strings using the Format function don't include a leading space reserved for the sign of the value; those converted using the Str function retain the leading space.

Remarks

If you are formatting a nonlocalized numeric string, you should use a user-defined numeric format to ensure that you get the look you want.

The String.Format method also provides similar functionality.

Example

This example shows various uses of the Format function to format values using both String formats and user-defined formats. For the date separator (/), time separator (:), and the AM/PM indicators (t and tt), the actual formatted output displayed by your system depends on the locale settings the code is using. When times and dates are displayed in the development environment, the short time format and short date format of the code locale are used.

Dim MyDateTime As Date = #1/27/2001 5:04:23 PM#Dim MyStr As String' Returns current system time in the system-defined long time format.MyStr = Format(Now(), "Long Time")' Returns current system date in the system-defined long date format.MyStr = Format(Now(), "Long Date")' Also returns current system date in the system-defined long date ' format, using the single letter code for the format.MyStr = Format(Now(), "D")' Returns the value of MyDateTime in user-defined date/time formats.MyStr = Format(MyDateTime, "h:m:s")   ' Returns "5:4:23".MyStr = Format(MyDateTime, "hh:mm:ss tt")   ' Returns "05:04:23 PM".MyStr = Format(MyDateTime, "dddd, MMM d yyyy")   ' Returns "Saturday,   ' Jan 27 2001".MyStr = Format(MyDateTime, "HH:mm:ss")   ' Returns "17:04:23"MyStr = Format(23)   ' Returns "23".' User-defined numeric formats.MyStr = Format(5459.4, "##,##0.00")   ' Returns "5,459.40".MyStr = Format(334.9, "###0.00")   ' Returns "334.90".MyStr = Format(5, "0.00%")   ' Returns "500.00%".

Ответить

Страница: 1 |

Поиск по форуму



© Copyright 2002-2011 VBNet.RU | Пишите нам