[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 215
  • Last Modified:

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

How do I make sure data in a textbox is numerical and in currency format like the following below

320.00

I am using VB6
0
al4629740
Asked:
al4629740
3 Solutions
 
sammySeltzerCommented:
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}") %>' >



0
 
al4629740Author Commented:
is that for visual basic 6?
0
 
raysonleeCommented:
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")
Else
  Error handling....
End If
0
 
Martin LissRetired ProgrammerCommented:
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.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now