viusal基本输入验证整数 [英] viusal basic input validation integer

查看:68
本文介绍了viusal基本输入验证整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Visual Basic(不是点网)

检查用户输入整数的最佳方法是什么?
输入框?

isNumeric()检查数值..但不通知数字

带小数位

inputBox返回一个字符串,所以我可以检查小数点???这似乎

就像矫枉过正


返回的值可以归为整数类型,然后是单个

类型......这两个可以比较..但如果小数部分为零,这仍然没有抱怨

带小数位的数字


什么是简单的解决方案?


cw

解决方案

code_wrong写道:

Visual基本(不是点网)
检查用户输入整数的最佳方法是什么?



使用蒙面输入框在击键时拒绝无效条目。


查找屏蔽输入 - VB6有很多选项。 6年前。


尽快升级到动态OO语言。 VB6会带给你




-

Phlip
http://www.greencheese.org/ZeekLand < - 不是博客!!!




" Phlip" < pH值******* @ gmail.com>在消息中写道

news:ia ****************** @ newssvr30.news.prodigy.c om ...

code_wrong写道:

Visual Basic(不是点网)
检查用户输入整数的最佳方法是什么?
InputBox?



使用屏蔽输入框拒绝按键时的无效条目。

查找屏蔽输入 - VB6有很多选项。 6年前。

尽快升级到动态OO语言。 VB6将带来

下来。




不幸的是我被限制使用inputbox()...为什么? ..如果我现在改变输入方法,学生可能会受到创伤......

这些都是很早的时候


> Visual Basic(不是dot net)

检查用户输入整数的最佳方法是什么?



以下是我过去发布的类似

问题的两个函数.....一个仅用于数字,另一个用于常规

数字:


函数IsDigitsOnly(值为字符串)为布尔值

IsDigitsOnly = Len(Value)> 0和_

非价值类似* [!0-9] *"

结束功能


函数IsNumber (ByVal Value As String)作为布尔值

''如果你不想要提供加号/减号的话,请保留下一个语句
如果值类似于[+ - ] *然后Value = Mid


Visual Basic (not dot net)
what is the best way to check the User has entered an integer into an
InputBox?

isNumeric() checks for a numeric value .. but does not notify of numbers
with decimal places
inputBox returns a string so I could check for decimal point??? this seems
like overkill

The value returned can be asigned into an Integer type and then a Single
type ... the two can be compared .. but still this does not complain about
numbers with decimal places if the fractional part is zero

what is the simple solution?

cw

解决方案

code_wrong wrote:

Visual Basic (not dot net)
what is the best way to check the User has entered an integer into an
InputBox?



Use a masked input box that rejects invalid entries at the keystroke.

Look up "masked input" - there were lots of options for VB6. 6 years ago.

And upgrade to a dynamic OO language as soon as you can. VB6 will bring you
down.

--
Phlip
http://www.greencheese.org/ZeekLand <-- NOT a blog!!!



"Phlip" <ph*******@gmail.com> wrote in message
news:ia******************@newssvr30.news.prodigy.c om...

code_wrong wrote:

Visual Basic (not dot net)
what is the best way to check the User has entered an integer into an
InputBox?



Use a masked input box that rejects invalid entries at the keystroke.

Look up "masked input" - there were lots of options for VB6. 6 years ago.

And upgrade to a dynamic OO language as soon as you can. VB6 will bring
you
down.



unfortunately I am restricted to using inputbox() ... why? .. if I change
the method for input now, the students will likely will be traumatised ..
these are very early days


> Visual Basic (not dot net)

what is the best way to check the User has entered an integer into an
InputBox?



Here are two functions that I have posted in the past for similar
questions..... one is for digits only and the other is for "regular"
numbers:

Function IsDigitsOnly(Value As String) As Boolean
IsDigitsOnly = Len(Value) > 0 And _
Not Value Like "*[!0-9]*"
End Function

Function IsNumber(ByVal Value As String) As Boolean
'' Leave the next statement out if you don''t
'' want to provide for plus/minus signs
If Value Like "[+-]*" Then Value = Mid


这篇关于viusal基本输入验证整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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