?
Solved

Highlight Text With Textbox Control

Posted on 2002-05-20
1
Medium Priority
?
194 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 200 total points
ID: 7022225
With txtAdjFundingAmt
    .SetFocus
    .Text = "0"
    .SelStart = 0
    .SelLength = Len(.Text)
End With
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

719 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