zoukankan      html  css  js  c++  java
  • 让TextBox只输入金额或数字的方法

    Private Sub Form_Load (   )  
          Text1.Tag   =   0
          Text1_LostFocus
    End Sub

    Private Sub Text1_GotFocus (   )  
          Text1.Text   =   Text1.Tag
          Text1.SelStart   =   0
          Text1.SelLength   =   Len ( Text1.Text )  
    End Sub

    Private Sub Text1_KeyPress ( KeyAscii As Integer )  
          If KeyAscii > =   Asc ( "0" )   And KeyAscii < =   Asc ( "9" )   Or KeyAscii   =   8 Or KeyAscii   =   Asc ( "." )   Then
                If KeyAscii   =   Asc ( "." )   And InStr ( 1, Text1.Text, ".", vbTextCompare )   > 0 Then
                      KeyAscii   =   0
                End If
                If Text1.SelStart > =   Len ( Text1.Text )   - 2 And _
                      InStr ( 1, Text1.Text, ".", vbTextCompare )   > 0 And _
                      Len ( Text1.Text )   - InstrRev ( Text1.Text, "."Len ( Text1.Text ) , vbTextCompare )   > =   2 And _
                      KeyAscii <> 8 Then
                       
                      KeyAscii   =   0
                End If
          Else
                KeyAscii   =   0
          End If
    End Sub

    Private Sub Text1_LostFocus (   )  
          Dim SaveNumer As Currency
          If IsNumeric ( Text1.Text )     =   False Then
                SaveNumer   =   0
          Else
                SaveNumer   =   Format ( Text1.Text, "0.00" )  
          End If
          Text1.Tag   =   SaveNumer
          Text1.Text   =   Format ( SaveNumer, "¥0.00" )  
    End Sub

  • 相关阅读:
    【PowerDesigner】【2】将工具栏显示出来
    【PowerDesigner】【1】简单介绍
    【服务器】【Windows】【4】删除Windows系统中不想要的服务
    【Java】【8】StringUtils中isNotEmpty和isNotBlank的区别
    【Java】【7】枚举类
    hdu 1285
    Codeforces Round #198 (Div. 2) —— D
    Codeforces Round #198 (Div. 2) —— C
    Codeforces Round #198 (Div. 2) —— B
    Codeforces Round #198 (Div. 2) —— A
  • 原文地址:https://www.cnblogs.com/rosesmall/p/14445195.html
Copyright © 2011-2022 走看看