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

  • 相关阅读:
    iOS MJRefresh的使用 (列表上拉加载更多)
    iOS 后台任务
    ios Alamofire网络插件的使用
    springboot shiro ehcache redis 简单使用
    android BottomNavigationView 简单使用
    iOS ksyhttpcache音视频缓存
    springboot 简单使用shiro登录
    springboot 使用 mybatis + mapper
    [LeetCode] Permutations
    【经典算法】回溯算法
  • 原文地址:https://www.cnblogs.com/rosesmall/p/14445195.html
Copyright © 2011-2022 走看看