isnumeric编译错误... [英] isnumeric compile error...

查看:104
本文介绍了isnumeric编译错误...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在immed窗口中测试了以下内容:


?isnumeric(1)

True

?isnumeric(1 。)



?isnumeric(1.2)



?isnumeric(1.2.2)


最后一个不打印True或False。

相反,A97抱怨编译错误。

我真的更喜欢False ,如果是这样的话,那就是b $ b。什么是最好的方式不被

困扰错误而只是假设

错误返回?


试验CStr并不富有成效

因为1.2.2既不是有效的数字

表达式也不是有效的字符串表达式。

所以,我能做什么如果我发现自己需要

来处理?CStr(1.2.2)以同样的方式处理

?CStr(1.2.2)将被处理。


如果用户在未绑定的text-

框中输入1.2.2,期望有效的数字输入,我希望
非常喜欢在

代码中确定它不是一个有效的数字。

但IsNumeric(1.2.2)不是答案

并且IsNumeric都不是(CStr(1.2.2))。那么

我该怎么办?

I have tested the following in immed window:

?isnumeric(1)
True
?isnumeric(1.)
True
?isnumeric(1.2)
True
?isnumeric(1.2.2)

The last one does not print True nor False.
Instead, A97 complains of a compile error.
I would really prefer False, should such be
the case. What''s the best way not to be
bothered with the error and just assume
False is returned?

Experimenting with CStr was not fruitful
because 1.2.2 is neither a valid numeric
expression nor a valid string expression.
So, what can I do if I find myself needing
to process ?CStr(1.2.2) in the same way
?CStr("1.2.2") would be processed.

If a user enters 1.2.2 in an unbound text-
box expecting a valid numeric entry, I
would like very much to determine, in
code, that it is NOT a valid numeric.
But IsNumeric(1.2.2) is not the answer
and neither is IsNumeric(CStr(1.2.2)). So
what do I do?

推荐答案

MLH写道:
MLH wrote:

我在immed窗口中测试过以下内容:


?isnumeric(1)

True

?isnumeric( 1.)

True

?isnumeric(1.2)

True

?isnumeric(1.2.2)


最后一个不打印真或假。

相反,A97抱怨编译错误。

我真的更喜欢这是假的,应该是这样的。什么是最好的方式不被

困扰错误而只是假设

错误返回?


试验CStr并不富有成效

因为1.2.2既不是有效的数字

表达式也不是有效的字符串表达式。
I have tested the following in immed window:

?isnumeric(1)
True
?isnumeric(1.)
True
?isnumeric(1.2)
True
?isnumeric(1.2.2)

The last one does not print True nor False.
Instead, A97 complains of a compile error.
I would really prefer False, should such be
the case. What''s the best way not to be
bothered with the error and just assume
False is returned?

Experimenting with CStr was not fruitful
because 1.2.2 is neither a valid numeric
expression nor a valid string expression.



为什么它不是一个有效的字符串?

Why is it not a valid string?


所以,如果我发现自己该怎么办?需要

处理?CStr(1.2.2)以同样的方式处理

?CStr(1.2.2)将被处理。
So, what can I do if I find myself needing
to process ?CStr(1.2.2) in the same way
?CStr("1.2.2") would be processed.



在它周围加上报价。您正在调试,而不是表单或报表或查询或

表。

Put quotes around it. You''re in debug, not a form or report or query or
table.


如果用户输入1.2.2未绑定的文字 -

包装盒期待有效的数字输入,我想要在b / b
代码中确定它不是a b有效的数字。

但IsNumeric(1.2.2)不是答案

,也不是IsNumeric(CStr(1.2.2))。所以

我该怎么办?
If a user enters 1.2.2 in an unbound text-
box expecting a valid numeric entry, I
would like very much to determine, in
code, that it is NOT a valid numeric.
But IsNumeric(1.2.2) is not the answer
and neither is IsNumeric(CStr(1.2.2)). So
what do I do?



我创建了一个表单。我添加了一个文本框。在AfterUpdate事件中,我有以下代码



私有子Text2_AfterUpdate()

如果IsNumeric(Me.Text2)那么

MsgBox" Numeric"

Else

MsgBox" Alpha"

结束子


我输入了1.2.2,我得到了Alpha。这是正确的。


使用表格和输入数据到

immedicate窗口之间有区别。

I created a form. I added a textbox. In the AfterUpdate event I have
the following code.
Private Sub Text2_AfterUpdate()
If IsNumeric(Me.Text2) Then
MsgBox "Numeric"
Else
MsgBox "Alpha"
End If
End Sub

I entered 1.2.2 and I got "Alpha". Which is correct.

There''s a difference between using a form and entering data into an
immedicate window.


On Sun,2008年7月27日19:50:17 -0700,Salad< oi*@vinegar.comwrote:


嗨沙拉,

我不同意你的断言使用

a形式和将数据输入到一个临时窗口之间有区别至少当它出现在IsNumeric的表现时。这两个环境使用相同的

VBA来完成他们的工作。


原因是数字(1.2.2)失败而其他的MLH提到

成功是这个没有转换为数字或字符串。

帮助文件说IsNumeric带一个数字或一个字符串。 1.2.2既不是
也不是b $ b。这就是它失败的原因。

-Tom。

Microsoft Access MVP
On Sun, 27 Jul 2008 19:50:17 -0700, Salad <oi*@vinegar.comwrote:

Hi Salad,
I don''t agree with your assertion "There''s a difference between using
a form and entering data into an immedicate window" at least when it
comes to the performance of IsNumeric. Both environments use the same
VBA to do their job.

The reason isnumeric(1.2.2) fails whereas the other ones MLH mentions
succeed is that this one does not convert to a number or a string.
The help file says that IsNumeric takes a number or a string. 1.2.2 is
neither. That''s why it fails.

-Tom.
Microsoft Access MVP

> MLH写道:
>MLH wrote:

>我在immed窗口中测试了以下内容:

?isnumeric(1)
True
?isnumeric(1。)
真的
?isnumeric(1.2)
真的
?isnumeric(1.2.2)

最后一个不打印真或假。
相反,A97抱怨编译错误。
我真的更喜欢False,如果是这样的话。什么是最好的方式不被错误所困扰并且只是假设
错误返回?

试验CStr并不富有成效因为1.2。 2既不是有效的数字表达也不是有效的字符串表达式。
>I have tested the following in immed window:

?isnumeric(1)
True
?isnumeric(1.)
True
?isnumeric(1.2)
True
?isnumeric(1.2.2)

The last one does not print True nor False.
Instead, A97 complains of a compile error.
I would really prefer False, should such be
the case. What''s the best way not to be
bothered with the error and just assume
False is returned?

Experimenting with CStr was not fruitful
because 1.2.2 is neither a valid numeric
expression nor a valid string expression.


为什么它不是有效的字符串?


Why is it not a valid string?


>那么,如果我发现自己需要<我该怎么办?以相同的方式处理?CStr(1.2.2)
?CStr(1.2.2)将被处理。
>So, what can I do if I find myself needing
to process ?CStr(1.2.2) in the same way
?CStr("1.2.2") would be processed.


在它周围加上引号。您正在调试,而不是表单或报表或查询或
表。


Put quotes around it. You''re in debug, not a form or report or query or
table.


>如果用户在未绑定的文本中输入1.2.2 -
盒子期待一个有效的数字输入,我非常希望在
代码中确定它不是一个有效的数字。
但IsNumeric(1.2.2)不是答案
,也不是IsNumeric(CStr(1.2.2))。那么我该怎么办?
>If a user enters 1.2.2 in an unbound text-
box expecting a valid numeric entry, I
would like very much to determine, in
code, that it is NOT a valid numeric.
But IsNumeric(1.2.2) is not the answer
and neither is IsNumeric(CStr(1.2.2)). So
what do I do?


我创建了一个表单。我添加了一个文本框。在AfterUpdate事件中,我有以下代码。
Private Sub Text2_AfterUpdate()

如果是IsNumeric(Me.Text2)那么

MsgBox"数字

Else

MsgBox" Alpha"

结束如果
结束子

我进入了1.2.2我得到了Alpha。这是正确的。

使用表单和在
immedicate窗口中输入数据之间存在差异。


I created a form. I added a textbox. In the AfterUpdate event I have
the following code.
Private Sub Text2_AfterUpdate()
If IsNumeric(Me.Text2) Then
MsgBox "Numeric"
Else
MsgBox "Alpha"
End If
End Sub

I entered 1.2.2 and I got "Alpha". Which is correct.

There''s a difference between using a form and entering data into an
immedicate window.


Tom van Stiphout写道:
Tom van Stiphout wrote:

On Sun,2008年7月27日19:50: 17 -0700,Salad< oi*@vinegar.com写道:


嗨沙拉,

我不同意你的断言有'使用

a形式和将数据输入到一个immedicate窗口之间的区别是至少当它出现在IsNumeric的表现时。两种环境都使用相同的

VBA来完成他们的工作。
On Sun, 27 Jul 2008 19:50:17 -0700, Salad <oi*@vinegar.comwrote:

Hi Salad,
I don''t agree with your assertion "There''s a difference between using
a form and entering data into an immedicate window" at least when it
comes to the performance of IsNumeric. Both environments use the same
VBA to do their job.



我可以在没有引号的文本框中输入1.1.1并且IsNumeric工作

只是找到。


如果我在Debug中,输入1.1.1而不是引号是不正确的。这不是一个

数字,它是一个字符串。就像我写的那样?
? Isnumeric(嗨汤姆!)

我会期待一个错误。


我怀疑MLH如果他这样做会有错误

var =" 1.1.1"

? Isnumeric(var)


我在

表单中使用未绑定文本框得到准确结果的原因是我的opionion中的Text0类似于一个变量类型

variant。

I can enter 1.1.1 into a text box with no quotes and IsNumeric works
just find.

If I am in Debug, to enter 1.1.1 not in quotes is incorrect. Is isn''t a
number, it''s a string. It''s the same as if I wrote
? Isnumeric(Hi Tom!)
I''d expect an error.

I doubt MLH would have gotten an error if he did this
var = "1.1.1"
? Isnumeric(var)

The reason I would get an accurate result using an unbound textbox in a
form is that Text0, in my opionion, is similar to a variable of type
variant.


>

原因isnumeric(1.2.2)失败而其他的MLH提到

成功是这个没有转换为数字或字符串。

帮助文件说IsNumeric带一个数字或一个字符串。 1.2.2既不是
也不是b $ b。这就是它失败的原因。
>
The reason isnumeric(1.2.2) fails whereas the other ones MLH mentions
succeed is that this one does not convert to a number or a string.
The help file says that IsNumeric takes a number or a string. 1.2.2 is
neither. That''s why it fails.



我唯一能看到MLH发生错误的是他在调试/即时窗口中做了什么。对我来说,这是一个数据

条目,也许是他在调试窗口中做出的逻辑错误。 IOW ...用户错误。


就我而言,他所寻求的建议是他/她如何写b语句在调试窗口中,如果语句

不正确怎么办。

The only time I can see MLH''s error occurring is if he''s doing
everything from the debug/immediate window. To me, that is a data
entry, perhaps logic, error he made in the Debug window. IOW...user error.

The advice he was seeking, as far as I''m concerned, is how does he/she
write statements in the Debug window and what to do if the statement is
incorrect.


>

-Tom。

Microsoft Access MVP

>
-Tom.
Microsoft Access MVP


>> MLH写道:
>>MLH wrote:

>>>我在immed窗口中测试了以下内容:

?isnumeric(1)
真的
?isnumeric(1 。)
真的
?isnumeric(1.2)
真的
?isnumeric(1.2.2)

最后一个不打印True或False。
相反,A97抱怨编译错误。
我真的更喜欢False,如果是这样的话。什么是最好的方式不被错误所困扰并且只是假设
错误返回?

试验CStr并不富有成效因为1.2。 2既不是有效的数字表达也不是有效的字符串表达式。
>>>I have tested the following in immed window:

?isnumeric(1)
True
?isnumeric(1.)
True
?isnumeric(1.2)
True
?isnumeric(1.2.2)

The last one does not print True nor False.
Instead, A97 complains of a compile error.
I would really prefer False, should such be
the case. What''s the best way not to be
bothered with the error and just assume
False is returned?

Experimenting with CStr was not fruitful
because 1.2.2 is neither a valid numeric
expression nor a valid string expression.


为什么它不是有效的字符串?


Why is it not a valid string?


>>>那么,什么可以如果我发现自己需要以相同的方式处理CStr(1.2.2),我会这样做吗?CStr(1.2.2)将被处理。
>>>So, what can I do if I find myself needing
to process ?CStr(1.2.2) in the same way
?CStr("1.2.2") would be processed.


在它周围加上引号。你正在调试,而不是表格或报告或查询或
表。


Put quotes around it. You''re in debug, not a form or report or query or
table.


>>>如果是用户在未绑定的文本框中输入1.2.2,期望有效的数字输入,我非常希望在
代码中确定它不是有效的数字。
但IsNumeric(1.2.2)不是答案
,IsNumeric也不是(CStr(1.2.2))。那么我该怎么办?
>>>If a user enters 1.2.2 in an unbound text-
box expecting a valid numeric entry, I
would like very much to determine, in
code, that it is NOT a valid numeric.
But IsNumeric(1.2.2) is not the answer
and neither is IsNumeric(CStr(1.2.2)). So
what do I do?


我创建了一个表单。我添加了一个文本框。在AfterUpdate事件中,我有以下代码。
Private Sub Text2_AfterUpdate()
如果IsNumeric(Me.Text2)那么
MsgBoxNumeric
Else
MsgBox" Alpha"
结束如果
结束子

我输入1.2.2并且我得到了Alpha。这是正确的。

使用表单和在
immedicate窗口中输入数据之间存在差异。


I created a form. I added a textbox. In the AfterUpdate event I have
the following code.
Private Sub Text2_AfterUpdate()
If IsNumeric(Me.Text2) Then
MsgBox "Numeric"
Else
MsgBox "Alpha"
End If
End Sub

I entered 1.2.2 and I got "Alpha". Which is correct.

There''s a difference between using a form and entering data into an
immedicate window.


这篇关于isnumeric编译错误...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆