Using MsgBox or InputBox

L

LA Lawyer

I want to use a MsgBox or InputBox, rather than a form, to capture a single letter, e.g., a, b, c, d or e.

Is that possible? How is that done?
 
G

Graham Mandeno

Hi LA Lawyer

strLetter = InputBox( "Enter a letter:")
Select Case Len(strLetter)
Case 0
' nothing was entered or cancel was clicked
Case 1
' only one character
Case Else
' more than one character
strLetter = Left(strLetter, 1)
End Select

--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand

I want to use a MsgBox or InputBox, rather than a form, to capture a single
letter, e.g., a, b, c, d or e.

Is that possible? How is that done?
 
D

Douglas J. Steele

It's definitely not possible using a message box.

What do you want to do with the value? To capture a single letter, you can
use something like:

Dim strInput As String

strInput = InputBox("Input a single letter")
If Len(strInput) <> 1 Then
MsgBox "I said a single letter!"
ElseIf UCase(strInput) < "A" Or UCase(strInput) > "Z" Then
MsgBox "I said a letter!"
Else
' at this point, you can assume that strInput contains a single letter
End If


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


I want to use a MsgBox or InputBox, rather than a form, to capture a single
letter, e.g., a, b, c, d or e.

Is that possible? How is that done?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top