Many thanks Alan, I'll give it a try.  I knew Profox would come up with the 
goods 😊

John

John Weller
07976 393631

> -----Original Message-----
> From: ProfoxTech <profoxtech-boun...@leafe.com> On Behalf Of Alan Bourke
> Sent: 10 January 2022 14:58
> To: profoxt...@leafe.com
> Subject: Re: [NF] Help With VB.Net
> 
> Assuming you are using Windows Forms and not WPF ...
> 
> You can detect an 'Enter' keypress via the KeyPress event.
> 
>     Private Sub TextBox1_KeyPress(sender As Object, e As KeyPressEventArgs)
> Handles TextBox1.KeyPress
>         If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Return) Then
>             MessageBox.Show("Enter")
>         End If
>     End Sub
> 
> That won't detect focus leaving the textbox via tab or mouse click etc though.
> For that you might have to use the Validating event.
> 
>     Private Sub TextBox1_Validating(sender As Object, e As
> System.ComponentModel.CancelEventArgs) Handles TextBox1.Validating
> 
>         Dim isValid As Boolean
> 
>         isValid = True          ' Check what you need to check here.
> 
>         If isValid = False Then
>             e.Cancel = True
>         End If
> 
>     End Sub
> 
> 
> 
> --
>   Alan Bourke
>   alanpbourke (at) fastmail (dot) fm
> 
> On Mon, 10 Jan 2022, at 2:14 PM, j...@johnweller.co.uk wrote:
> > I am trying to help a friend write an app in VB.Net.  I need some code
> > to fire when a number is entered into a textbox and Enter pressed, as
> > in the Valid event in VFP, but can’t seem to find the appropriate VB
> > event – any suggestions gratefully received.  I’m asking here because
> > it is easier to specify the problem in VFP terms 😊
> >
> >
> >
> > TIA
> >
> >
> >
> > John
> >
> >
> >
> > John Weller
> >
> > 07976 393631
> >
> >
> >
> >
> >
> > --- StripMime Report -- processed MIME parts --- multipart/alternative
> >   text/plain (text body -- kept)
> >   text/html
> > ---
> >
[excessive quoting removed by server]

_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: https://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: https://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: https://leafe.com/archives
This message: 
https://leafe.com/archives/byMID/013701d80633$43815dc0$ca841940$@johnweller.co.uk
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to