Solved

Highlight Text With Textbox Control

Posted on 2002-05-20
1
168 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
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
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…

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now