Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 525147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:38:29+00:00 2026-05-13T08:38:29+00:00

Basically I have a series of lines in a textbox like this: ### =

  • 0

Basically I have a series of lines in a textbox like this:

### = 1232, 1234, 1236, 1238, 123A, 123C ; comment here
I want to show a button when the caret (cursor pipe thing) in the textbox goes is in a number so like:

... , 12|31, .... or
... , 123|1, .... etc
(the pipe being the caret)

I have written code to check if it is in a number and to get the number when the button is clicked, but it doesn’t work correctly if I put the code in the selection changed event.

oh and the numbers can be upto 8 digits long and hex.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T08:38:29+00:00Added an answer on May 13, 2026 at 8:38 am

    TextBox doesn’t have an event that tells you that the user moved the caret. You’ll have to synthesize one, possible with the Application.OnIdle event. It runs after all input events (mouse, keyboard) are processed. You’ll do a bit of extra unnecessary work but you’ll never notice since this code runs in “human-time”. For example:

    Public Class Form1
    
      Public Sub New()
        InitializeComponent()
        AddHandler Application.Idle, AddressOf UpdateButtonState
      End Sub
    
      Private Sub updateButtonState(ByVal sender As Object, ByVal e As EventArgs)
        Const hexdigits As String = "0123456789ABCDEF"
        Dim caretPos As Integer = TextBox1.SelectionStart
        Dim enable As Boolean = caretPos > 0 AndAlso caretPos < TextBox1.Text.Length
        If enable Then
          Dim left As Char = Char.ToUpper(TextBox1.Text(caretPos - 1))
          Dim right As Char = Char.ToUpper(TextBox1.Text(caretPos))
          If Not hexdigits.Contains(left) OrElse Not hexdigits.Contains(right) Then enable = False
        End If
        Button1.Enabled = enable
      End Sub
    End Class
    

    If the extra work bothers you then check if the text box has the focus and keep track of its last SelectionStart value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I have a series of projects displayed on the page. Each project consists
Basically I have a series of divs which contains a label and an input
Sorry if the title doesn't make sense. Basically I have a series of strings
I basically have three tables, posts, images and postimages (this simply contains the ids
I have a series of index files for some data files which basically take
I have a series of databases, each of which is basically standalone. It initially
I was wondering if someone could help with this: I have a series of
I have a line series chart called lineSeries1. I would like that chart to
I have generated a series of rows using C# and VSTO. I have basically
I have series of divs, that represent similar to a chess board. but this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.