|
-
Oct 6th, 2009, 07:31 PM
#1
Thread Starter
New Member
[RESOLVED] help keypress "VbkeyReturn"
im making a simple login form,
i want to use the keypress,
when i enter my username and password and hit the enterkey,
the form2 will appear and also the msgbox if the username and password,is wrong.this what i have,but is not working,pls help what is worng or what should i do...tanx
Code:
Private Sub Command1_Click()
If Text1.Text = "aaa" And Text2.Text = "111" Then
Form2.Show
Unload Me
Else
MsgBox "wrong"
Text1.SetFocus
Text1.Text = ""
Text2.Text = ""
End If
Form1.KeyPreview = True
End Sub
Private Sub Command1_KeyPress(KeyAscii As Integer)
Select Case KeyCode
Case vbKey13
Call Command1_Click
End Select
End Sub
Last edited by RobDog888; Oct 6th, 2009 at 08:00 PM.
Reason: Added [code] tags
-
Oct 6th, 2009, 08:02 PM
#2
Re: help keypress "VbkeyReturn"
Welcome to the Forums.
Set the KeyPreview property of your Form1 from your property grid window instead of at runtime in the command1_click event, it will be too late to receive the prop change at that time.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Oct 6th, 2009, 09:52 PM
#3
Re: help keypress "VbkeyReturn"
u can set the command button default property = true, then if u press enter, command_click event wil be executed.
-
Oct 7th, 2009, 11:44 AM
#4
Re: help keypress "VbkeyReturn"
 Originally Posted by jhamez
Private Sub Command1_KeyPress(KeyAscii As Integer)
Select Case KeyCode
Case vbKey13
Call Command1_Click
End Select
End Sub[/code]
There is no KeyCode in a KeyPress event.
Code:
Private Sub Command1_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then
Command1.Value = True
End If
End Sub
-
Oct 8th, 2009, 12:51 AM
#5
Thread Starter
New Member
Re: help keypress "VbkeyReturn"
tanx for d help....
-
Oct 8th, 2009, 12:54 AM
#6
Re: help keypress "VbkeyReturn"
We are glad to have helped.
Ps, dontforget to mark your thread as Resolved from the Thread Tools so others will know your question has been answered.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|