syntax for to upper case letters?

  • Thread starter Thread starter dex
  • Start date Start date
D

dex

Hi I have a form coded involving the characters "P" and "Q". But I need
the form to still run without any runtime errors even though the user
enters a lower case p or q. Whats the syntax for the to upper case
letters. Here is my code. Keep in mind that this code works, I just
need to add the to upper statement.

r = Application.CountA(Range("A:A"))

If Left(parttxt.Text, 1) = "P" And Left(qtytxt.Text, 1) = "Q" Then
Range("A1").Offset(r + 1, 0) = Me.parttxt.Value
Range("B1").Offset(r + 1, 0) = Me.qtytxt.Value
Me.parttxt.Value = ""
Me.qtytxt.Value = ""
Me.parttxt.SetFocus
Else: MsgBox "Wrong Part or Qty Scanned", vbCritical
Me.parttxt.Value = ""
Me.qtytxt.Value = ""
Me.parttxt.SetFocus


End If
End Sub
 
try this

If UCase(Left(parttxt.Text, 1)) = "P" And UCase(Left(qtytxt.Text, 1)) = "Q"
Then
 
Include 'Option Compare Text' at the top of the module and VBA will get it
right anyway. Alternatively, use the UCase$() function.
 
Hi dex,
My guess is change the If line to:

If (Left(parttxt.Text, 1) = "P" Or Left(parttxt.Text, 1) = "p") And
(Left(qtytxt.Text, 1) = "Q" Or Left(qtytxt.Text, 1) = "q") Then

But it's only a guess!

Ken Johnson
 

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

Back
Top