Solved

Highlight Text With Textbox Control

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

810 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