首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >修复IsNumeric循环错误?

修复IsNumeric循环错误?
EN

Stack Overflow用户
提问于 2015-06-04 17:01:38
回答 1查看 46关注 0票数 1

我试图修复一个简单的循环,以便在用户输入整数之前消息框不会消失。这是我的代码:

代码语言:javascript
复制
Sub PlateMicro()

strName = InputBox(Prompt:="Enter number of wells in plate. The default is 96 (8X12).", _
      Title:="PLATE SETUP", Default:="96")

Dim wellCount As Object
Dim numericCheck As Boolean
numericCheck = IsNumeric(wellCount)

If IsNumeric(wellCount) Then
Range("A1").Value = wellCount 'Enter the number of plate wells selected into template.
Else: strName = InputBox(Prompt:="You must enter an integer. Enter number of wells in plate. The default is 96 (8X12)." _
      , Title:="PLATE SETUP", Default:=userDefaultChoice)
End If
End Sub
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-06-04 17:13:06

考虑:

代码语言:javascript
复制
Sub intCHECK()
   Dim var As Variant
   var = "whatever"
   While Not IsNumeric(var)
      var = Application.InputBox(Prompt:="Enter integer", Type:=2)
   Wend

   MsgBox "Thanks!"
End Sub

这将允许您在触摸Cancel时退出

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30649921

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档