确保输入框条目只有1个字母 [英] making sure an inputbox entry is 1 letter only

查看:74
本文介绍了确保输入框条目只有1个字母的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何做到这一点,如果有人在一个输入框中键入多个字母,然后另一个输入框显示告诉用户仅输入1个字母?

我尝试过:

              如果Char.IsLetter(LetterGuess)> 1然后
                             InputBox(请仅输入1个字母")
                  

我没有收到任何错误,但这没有用.

有什么建议吗?

我已经有了它,这样用户就不能输入数字或特殊字符,只能输入字母.

此外,如何通过使用显示请输入尚未输入的字母"的输入框来确保不重复输入字母?

解决方案



怎么样呢?

将inputChr转换为字符串
inputChr = InputBox(输入字母","InputBox")
选择案例输入长度
案例= 0
MessageBox.Show(无输入")
案例= 1
MessageBox.Show("OK:仅输入一个字母")
其他情况
MessageBox.Show("Err:输入多个字母")
结束选择



How do I make it so that if someone types more than 1 letter into an inputbox, another inputbox displays telling the user to only enter 1 letter?

I tried this: 

                If Char.IsLetter(LetterGuess) > 1 Then
                InputBox("Please enter only 1 letter")
                End If

I didn't get any errors, but it didn't work.

Any suggestions?

I already have it so that way the user cannot enter a number or a special character, only letters.

Also, how do I make sure that a letter entry is not repeated, by using an inputbox that says "please enter a letter that wasn't entered already"?

解决方案

Hi

How about this?

Dim inputChr As String
inputChr = InputBox("Input letters", "InputBox")
Select Case inputChr.Length
	Case = 0
		MessageBox.Show("no input")
	Case = 1
		MessageBox.Show("OK: only one letter input")
	Case Else
		MessageBox.Show("Err: more than one letter input")
End Select



这篇关于确保输入框条目只有1个字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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