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

  • 相关阅读:
    前端vue使用js-xlsx导出excel的三种方法
    vue使用echarts绘制河南地图并实现个人轨迹
    VUE中使用Echarts绘制柱状图
    springboot项目配置拦截器
    springboot+mybatis的多数据源配置
    Java后端高频面试题汇总
    Java基础专题
    Java集合专题
    Java并发专题
    JVM专题javascript:;
  • 原文地址:https://www.cnblogs.com/rosesmall/p/14445195.html
Copyright © 2011-2022 走看看