| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 5508 人关注过本帖
标题:transform()函数的使用
只看楼主 加入收藏
我爱vf
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2006-10-8
收藏
 问题点数:0 回复次数:3 
transform()函数的使用
今天我参加了系里组织的一个计算机程序设计大赛.我做的一个题目是设计一个计算器.功能有实现常见的计算问题,简单的NOT,AND,OR等运算,和二进制,十进制的转换功能.但是十进制和二进制转换的函数我记不起来了,所以这个功能我也没有实现.最后比赛完了上网查到了transform(exp,expc)函数,但是查不到具体的使用方法.各位同志,如果晓得的话,可否指点一二.还有我在怀疑这个函数能不能实现这个二进制和十进制转换的功能.
搜索更多相关主题的帖子: 函数 transform 二进制 计算器 十进制 
2006-11-18 20:03
hu9jj
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:红土地
等 级:贵宾
威 望:400
帖 子:11826
专家分:43421
注 册:2006-5-13
收藏
得分:0 

这是从VFP6.0帮助文件中拷贝下来的,希望你能用得上。
TRANSFORM( ) Function
Example See Also

Returns a character string from an expression in a format determined by a format code.

Syntax

TRANSFORM(eExpression, [cFormatCodes])

Returns

Character

Arguments

eExpression

Specifies the character, currency, date, or numeric expression to format.

cFormatCodes

Specifies one or more format codes that determine how the expression is formatted. The following table lists the available format codes.

Format Codes Description
@C CR is appended to positive currency or numeric values to indicate a credit.
@D Date and DateTime values are converted to the current SET DATE format.
@E Date and DateTime values are converted to a BRITISH date format.
@R The transformation uses a format mask. The mask characters are not stored to the transformed value. Use only with character or numeric data. Mask characters include:
9 or #Represents a character or number.

!Converts lower-case letters to upper-case letters.

@T Leading and trailing spaces are trimmed from character values.
@X DB is appended to negative currency or numeric values to indicate a debit.
@Z If 0, currency or numeric values are converted to spaces.
@( Encloses negative currency or numeric values in parentheses.
@^ Converts currency or numeric values to scientific notation.
@0 Converts numeric or currency values to their hexadecimal equivalents. The numeric or currency value must be positive and less than 4,294,967,296.
@! Converts an entire character string to uppercase.
@$ Adds the current currency symbol specified by SET CURRENCY to currency and numeric values. By default, the symbol is placed immediately before or after the value. However, the currency symbol and its placement (specified with SET CURRENCY), the separator character (specified with SET SEPARATOR) and the decimal character (specified with SET POINT) can all be changed.
X Specifies the width of character values. For example, if cFormatCodes is 'XX', 2 characters are returned.
Y Converts logical true (.T.) and false (.F.) values to Y and N, respectively.
! Converts a lowercase character to uppercase in the corresponding position in a character string.
. Specifies the decimal point position in currency and numeric values.
, Separates digits to the left of the decimal point in currency and numeric values.


If you omit cFormatCodes, Visual FoxPro performs a default transformation on eExpression. The following table describes the transformation performed for each data type eExpression can assume:

Data Type Transformation Description
Character No transformation is performed.
Currency Transformation is determined by the settings specified in the Regional tab of the Options dialog box.
Date A DTOC( ) transformation is performed on the date.
DateTime A TTOC( ) transformation is performed on the date time.
Logical Logical true (.T.) and false (.F.) values are transformed to the character strings ".T." and ".F." respectively.
Numeric (includes Double, Float, or Integer data types) Trailing zeros are removed from the decimal portion of a numeric value. If the numeric value is a whole number, a decimal point is not included in the transformed value (for example, 4.0 is transformed to 4). If the numeric value is less than one but greater than negative one, zero is included before the decimal point (for example, .4 is transformed to 0.4).
General "Gen" is returned if the general field contains an object; "gen" is returned if the general field doesn't contain an object.
Memo No transformation is performed.


活到老,学到老!http://www.(该域名已经被ISP盗卖了)E-mail:hu-jj@
2006-11-19 11:29
zjy198277
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2006-11-26
收藏
得分:0 
晕,还是英文版的帮助
2006-11-26 21:13
Tiger5392
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:88
帖 子:2775
专家分:2237
注 册:2006-5-17
收藏
得分:0 

transform( ) 函数
示例 请参阅

用 @ ... SAY 中的 PICTURE 或 FUNCTION 代码格式化字符表达式或数值表达式。

语法

TRANSFORM(eExpression, [cFormatCodes])

返回值类型

字符型

参数

eExpression

指定要进行格式编排的数值或字符表达式。

cFormatCodes

指定一个或多个 PICTURE 或 FUNCTION 代码来决定如何对表达式进行格式编排。

格式代码 说明
@C CR 附加于正的货币型值或数值型值后面,表明该值是贷款。
@D 日期和日期时间值转换为 SET DATE 当前设置的格式。
@E 日期和日期时间值转换为 BRITISH 日期格式。
@R 使用格式掩码进行转化。掩码字符不保存到转化后的值。只用于字符型或数值型数据。掩码字符包括:
9 或 #代表一个字符或数值。

!将小写字母转化为大写字母。

@T 从字符值中删除前导和后续空格。
@X DB 附加于负的货币型值或数值型值后面,表明该值是借款。
@Z 如果为 0,则将货币型值或数值型值转化为空格。
@( 将负的货币型值或数值型值放在括号中。
@^ 将货币型值或数值型值转化为科学计数格式。
@0 将货币型值或数值型值转化为等价的十六进制格式。货币型值或数值型值必须是正的,并且小于 4,294,967,296。
@! 将整个字符串转化为大写。
@$ 将当前的货币符号添加到货币型值或数值型值,当前的货币符号是由 SET CURRENCY 指定的。在默认情况下,该符号紧放在该值的前面或后面。但是,当前的货币符号和位置(由 SET CURRENCY指定)、分隔字符(由 SET SEPARATOR 指定)和进制字符(由SET POINT 指定)都有可能改变。
X 指定字符值的宽度。例如,如果 cFormatCodes 为 'XX',则返回两个字符。
Y 将逻辑“真” (.T.) 和“假” (.F.) 分别转化为 Y 和 N。
! 将一个小写字符在字符串的相应位置转化为大写。
. 指定货币型值或数值型值中的小数点位置。
, 分隔货币型值或数值型值中小数点左方的数字。


如果省略 cFormatCodes,则 Visual FoxPro 对 eExpression 进行默认的转换。下表列出了对 eExpression 的每种数据类型的转换:

数据类型 转换说明
字符型 不进行转换。
货币型 所进行的转换由“选项”对话框“地区”选项卡中的设置决定。
日期型 对日期值进行 DTOC()转换。
日期时间型 对日期时间值进行 TTOC()转换。
逻辑型 将逻辑“真” (.T.) 和“假” (.F.) 分别转化为 T 和 F。
数值型(包括双精度型、浮点型或整型) 从数值型值的小数点部分删除后续零。如果该数值型值是一个整数,则在转换后值中不包含小数点(例如,4.0 转换为4)。如果该数值型值小于 1 大于负 1,则在小数点前面包含零(例如 .4 转换为 0.4)。
通用型 如果通用字段包含一个对象,则返回 "Gen";否则返回"gen"。
备注型 没有转换


感言:学以致用。 博客:http://www./blog/user14/65009/index.shtml email:Tiger5392@
2006-11-27 17:34
快速回复:transform()函数的使用
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014411 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved