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/ff7aa0e9-31a4-4925-86ec-11aaf958f...@www.fastmail.com ** 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.