473,386 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

checking input in inputbox

I was wondering if anyone knew of a way to control the text a user
types into an inputbox? I want the user to type in four letters only. I
can check the lenght by using the len() function in vba but I have no
idea how to check that each character is a letter. I realise I could
design a form to do this, but if the check could be done on an
inputbox, it would be so much easier.

Thanks in advance.

Nov 13 '05 #1
2 3274
This is untested, but should be close.

Dim strInput As String, bolOkInput, i as Integer, strCheckCharacter
Do
strInput = InputBox("Please give me your input.")
strInput = Trim(strInput)
If Len(strInput) <> 4 Then
bolOkInput = False
Msgbox "Input wrong length"
Else
For i = 1 To 4
strCheckCharacter = UCase(Mid(strInput, i, 1))
If Asc(strCheckCharacter) < 65 Or Asc(strCheckCharacter) > 90
Then
bolOkInput = False
Msgbox "Not all entered characters were alpha"
Exit For
Else
bolOkInput = True
End If
Next i
End If
Loop Until bolOkInput = True

--
Wayne Morgan
MS Access MVP
<mi********@hotmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
I was wondering if anyone knew of a way to control the text a user
types into an inputbox? I want the user to type in four letters only. I
can check the lenght by using the len() function in vba but I have no
idea how to check that each character is a letter. I realise I could
design a form to do this, but if the check could be done on an
inputbox, it would be so much easier.

Thanks in advance.

Nov 13 '05 #2
mi********@hotmail.com wrote:
I was wondering if anyone knew of a way to control the text a user
types into an inputbox? I want the user to type in four letters only. I
can check the lenght by using the len() function in vba but I have no
idea how to check that each character is a letter. I realise I could
design a form to do this, but if the check could be done on an
inputbox, it would be so much easier.

Thanks in advance.

The easiest way to do that is to create a form that looks like and acts
like an input box. Then you can check for key and mouse presses and
etc. You could even put in an input mask.
Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: J Buchman | last post by:
I am trying to do my VB 6 homework with an exercise that requires the use of variables, constants and string concatenation. I can't get the program to use the percentage that is put into the text...
3
by: Clare | last post by:
Hi I have a report that is made of 4 subreports. There is no actual information in the main report, and the record source is empty. In the Header section of the main report, I have a text box...
3
by: Wasim Akram | last post by:
Hi, Is there any pre defined InputBox (or similar) class in .net famework? = wa
5
by: Parveen | last post by:
I have a child form that calls an input box to receive information from a user during runtime. The code looks like this: strResult = InputBox("Enter new class code") I am having trouble...
3
by: SteveInBeloit | last post by:
hi, I have a small vb.net app that runs on a handheld device running CE. Using Visual Studio. I have decided I want to have then user enter a user name when it starts up. Is there a quick input...
3
by: Les | last post by:
Hi all, i have an input box that i need the user to put in a password and just wondered if it is possible to just show a * as he types in the letters as per the normal password inputbox ? any...
6
by: cj | last post by:
What's the .net (2003) "replacement" for the input box function?
1
by: solinear | last post by:
OK, I am going to preface this by saying I'm very new to VB coding (or any other kind, for that matter), but know a lot about Windows, AD and Security. We are making adjustments to our environment...
9
by: keydrive | last post by:
There must be a difference between a standard input field and a textbox field. I would like to use a textbox field and save the value in a hidden field for paging. This works in a default input...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.