key press event not working for "ENTER"

alcorjr

Active Member
Joined
Dec 29, 2002
Messages
416
I guys I'm trying to have this little script run from ENTER, and it's not doing it. Any ideas? :) :)
Code:
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
  TextBox1.EnterKeyBehavior = True

If KeyAscii = 13 Then
pwd = Me.TextBox1.Text
If Me.TextBox1.Text <> "" Then
If pwd = "matri" Or pwd = "leogr" Or pwd = "kgbkgb27" Then
Me.TextBox1.Text = Empty

Exit Sub
Else:
If Me.TextBox1.Text <> "" Then
    Dim msg9 As String
msg9 = "El password no es correcto"
CreateObject("WScript.Shell").Popup msg9, vbSystemnomode
Me.TextBox1.Text = Empty
pwd = Empty
End If
End If
End If
End If
End Sub

Thanks
 
alcorjr;



I read your post on the KeyPress Issue with interest.

I follow all the code except:::

What does

vbSystemnomode

do in your code
and why not just use

MsgBox msg9

instead of CreateObject("WScript.Shell").Popup msg9?

Yours in EXECLent Frustration

KniteMare
 
Upvote 0

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
To be honest with you, that script was given to me by someone on the forum some time ago, when I asked for a message box that would appear on top of anything that was on the screen. I've just copied it from previous projects. Haven't analyzed it.
I'm not even sure what the vbsystemnomode does. I've used Vbmodeless with the userforms, but the strange part is that I don't get a syntax error flag on it.

So, if you find some more info on it please lemme know.

Cheers (y)
 
Upvote 0

Forum statistics

Threads
1,215,168
Messages
6,123,408
Members
449,098
Latest member
ArturS75

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top