make sure data in a textbox is numerical and in currency format

Posted on 2011-10-23
Last Modified: 2012-05-12
How do I make sure data in a textbox is numerical and in currency format like the following below


I am using VB6
Question by:al4629740
    LVL 28

    Accepted Solution

    Something like this:

    <asp:TextBox ID="amount" runat="server" Text='<%# Bind("amount","{0:C2}") %>' >

    In your specific case,

    <asp:TextBox ID="amount" runat="server" Text='<%# Bind("320.00","{0:C2}") %>' >


    Author Comment

    is that for visual basic 6?
    LVL 9

    Assisted Solution

    In onchange event,

    Dim txtTemp as String
    txtTemp = TextBox1.Text.Replace("$", "")
    txtTemp = txtTemp.Text.Replace(",", "")
    If IsNumeric(txtTemp) Then
      TextBox1.Text = Format(txtTemp, "###,##0.00")
      Error handling....
    End If
    LVL 44

    Assisted Solution

    by:Martin Liss
    Here's an example from Microsoft. If you use Option Explicit (and you should) you'll need to add

       Dim mask_cents_pos As Integer
        Dim mask_dollars As Integer
        Dim tlen As Integer
        Dim tempo As String

    Open in new window

    at the start of the Masked_Key_Press sub.

    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

    This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
    Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
    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…
    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…

    755 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

    18 Experts available now in Live!

    Get 1:1 Help Now