ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 妙哉!函数段子手趣味讲函数 Excel服务器-会Excel,做管理系统 效率神器,一键搞定繁琐工作
HR薪酬管理数字化实战 Excel 2021函数公式学习大典 Excel数据透视表实战秘技 打造核心竞争力的职场宝典
让更多数据处理,一键完成 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
12
返回列表 发新帖
楼主: excelHelper

[求助]文本框的TEXT与VALUE这两个属性到底有什么区别

[复制链接]

TA的精华主题

TA的得分主题

发表于 2006-9-8 17:23 | 显示全部楼层
没有看清你的问题,我以为是在说单元格。

TA的精华主题

TA的得分主题

发表于 2006-9-8 18:37 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助
QUOTE:
以下是引用excelHelper在2006-9-8 16:41:35的发言:
QEE大哥,你的意思是在VB中有区别吗?能否提供一个这样的例子

在VB中标准的TEXTBOX是没有VALUE属性的.
因为TEXTBOX的值(VALUE)从名称上看也是文本型的(不然就不叫TEXTBOX了),所以就返回的数据类型和TEXT返回值不会有差异.同时,VBA(指EXCEL)的TEXTBOX又没有提供DATAFORMAT或FORMAT,NUMBERFORMAT之类的属性,其显示和实际值也是一样的.这是我下前面的结论的基本考虑.如果一定有些差别,可能在取值的速度上会有,但TEXTBOX我们不可能对其大量频繁使用,忽略之.
在有些语言中TEXTBOX有这两个属性的差别如WZSY2_MRF兄上面所说及其它的情况.
类似问题就不要深究了吧,VBA提供两个几乎一样的属性,只是微软的一种"贴心"而已,未必有什么玄机.个人观点.

TA的精华主题

TA的得分主题

发表于 2006-9-8 19:22 | 显示全部楼层

MSDN:

MSDN Home

Value Property

Note: To ensure compliance with upcoming versions of Internet Explorer, we are deprecating the use of some ActiveX controls on the site. Our apologies for the inconvenience. For alternatives, try viewing the Office 2003 VBA References or Office XP VBA Language References.                           

Specifies the state or content of a given control.

Syntax

object.Value [= Variant]

The Value property syntax has these parts:

PartDescription
objectRequired. A valid object.
VariantOptional. The state or content of the control.

Settings

ControlDescription
CheckBoxAn integer value indicating whether the item is selected:
 Null   Indicates the item is in a null state, neither selected nor cleared.
 1   True. Indicates the item is selected.
 0   False. Indicates the item is cleared.
OptionButtonSame as CheckBox.
ToggleButtonSame as CheckBox.
ScrollBarAn integer between the values specified for the Max and Min properties.
SpinButtonSame as ScrollBar.
ComboBox, ListBoxThe value in the BoundColumn of the currently selected rows.
CommandButtonAlways False.
MultiPageAn integer indicating the currently active page.
 Zero (0) indicates the first page. The maximum value is one less than the number of pages.
TextBoxThe text in the edit region.

Remarks

For a CommandButton, setting the Value property to True in a macro or procedure initiates the button's Click event.

For a ComboBox, changing the contents of Value does not change the value of BoundColumn. To add or delete entries in a ComboBox, you can use the AddItem or RemoveItem method.

For a TextBox, any value you assign to the Text property is also assigned to the Value property.

Value cannot be used with a multi-select ListBox.

TA的精华主题

TA的得分主题

发表于 2006-9-8 19:23 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册
 MSDN Home

Text Property

Note: To ensure compliance with upcoming versions of Internet Explorer, we are deprecating the use of some ActiveX controls on the site. Our apologies for the inconvenience. For alternatives, try viewing the Office 2003 VBA References or Office XP VBA Language References.                           

Returns or sets the text in a TextBox. Changes the selected row in a ComboBox or ListBox.

Syntax

object.Text [= String]

The Text property syntax has these parts:

PartDescription
objectRequired. A valid object.
StringOptional. A string expression specifying text. The default value is a zero-length string ("").

Remarks

For a TextBox, any value you assign to the Text property is also assigned to the Value property.

For a ComboBox, you can use Text to update the value of the control. If the value of Text matches an existing list entry, the value of the ListIndex property (the index of the current row) is set to the row that matches Text. If the value of Text does not match a row, ListIndex is set to 1.

For a ListBox, the value of Text must match an existing list entry. Specifying a value that does not match an existing list entry causes an error.

When the Text property of a ComboBox changes (such as when a user types an entry into the control), the new text is compared to the column of data specified by TextColumn.

You cannot use Text to change the value of an entry in a ComboBox or ListBox; use the Column or List property for this purpose.

The ForeColor property determines the color of the text.

TA的精华主题

TA的得分主题

 楼主| 发表于 2006-9-8 21:42 | 显示全部楼层

非常感谢wzsy2_mrf朋友、QEE用大哥与NORTHWOLVES版主热情支持

TA的精华主题

TA的得分主题

发表于 2010-4-10 20:07 | 显示全部楼层
在VBA中搞清楚text和value是很有必要的,我就遇到过这种情况,if cells(1,1).value="00:00:00" then ......它空格也会计算成0,结果是条件为真
和if cells(1,1).text="00:00:00" then........不同它是文件,有就有,没有就没有。我发现错误又不知道错在那儿,我搞了办法天解决了

TA的精华主题

TA的得分主题

发表于 2021-3-16 20:17 | 显示全部楼层

TA的精华主题

TA的得分主题

发表于 2021-3-16 22:01 来自手机 | 显示全部楼层
你看到的是text,实际上是value!text是value根据单元格式设定显示的内容

TA的精华主题

TA的得分主题

发表于 2024-11-14 11:25 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助
本帖最后由 Asv654132 于 2024-11-14 11:27 编辑

If Fix(textbox1.Text) <> textbox1.Text Then MsgBox “文本框的内容不是整数”    '正常运行
If Fix(textbox1.value) <> textbox1.value Then MsgBox “文本框的内容不是整数”    '逻辑有误,两者必定不相等,原因未知

您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2024-11-21 20:45 , Processed in 0.042992 second(s), 7 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

快速回复 返回顶部 返回列表