Solved

Highlight Text With Textbox Control

Posted on 2002-05-20
1
184 Views
Last Modified: 2010-05-02
I'm using VB6 against an SQL Server database.
I have a small routine which, if a user enters an invalid value, checks for a valid numeric number,resets the textbox to zero, and sets the focus to this field.
I'd like to highlight this section of text for the user, too.
Is there a way to do this with a normal textbox control or do I have to use a richtextbox control?
-------------------------------------------
Here's my routine in the LostFocus() event:
--------------------------------------------
If Not IsNumeric(txtAdjFundingAmt) Then
        MsgBox "Please Enter A Numeric Value", , "Adjusted Funding Amount"
        txtAdjFundingAmt.SetFocus
        txtAdjFundingAmt.Text = 0
    Else
        txtAdjFundingAmt = Format$(txtAdjFundingAmt, "###,###,###,##0")
    End If
-----------------------------------------------
I tried the richtextbox but it didn't like my error-checking routine and didn't allow the user to exit the textfield after an incorrect entry.

Thanks in advance.
John
0
Comment
Question by:jtrapat1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 28

Accepted Solution

by:
AzraSound earned 50 total points
ID: 7022225
With txtAdjFundingAmt
    .SetFocus
    .Text = "0"
    .SelStart = 0
    .SelLength = Len(.Text)
End With
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question