| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1053 人关注过本帖
标题:下面文本框输入格式如何做到
只看楼主 加入收藏
逐日
Rank: 2
等 级:新手上路
威 望:5
帖 子:117
专家分:2
注 册:2008-9-22
收藏
 问题点数:0 回复次数:6 
下面文本框输入格式如何做到
键入小数点后输入的数字移到小数点后
图片附件: 游客没有浏览图片的权限,请 登录注册
搜索更多相关主题的帖子: 文本 格式 输入 
2008-11-26 16:46
我是菜鸟哦
Rank: 6Rank: 6
等 级:贵宾
威 望:22
帖 子:921
专家分:209
注 册:2007-5-4
收藏
得分:0 
定点小数

偶是菜鸟鸟偶惧WHO?!!!!
2008-11-26 17:30
pariszh
该用户已被删除
收藏
得分:0 
提示: 作者被禁止或删除 内容自动屏蔽
2008-11-26 19:05
bccnvb6
Rank: 2
等 级:论坛游民
帖 子:28
专家分:15
注 册:2008-10-17
收藏
得分:0 
Private Sub Form_Load()
Text1.Text = "0.00"
End Sub

Private Sub Text1_Change()
Text1.SelStart = Len(Text1.Text)
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)

If KeyAscii >= 48 And KeyAscii <= 57 Then
    If Text1.Text = "0.00" Then
        Label1.Caption = "0.00"
        Else
        If Text1.Text = "0.000" Then
            Text1.Text = "0.00"
            Else
            c = Len(Text1.Text)
            If c < 6 Then
                If Left(Text1.Text, 2) = "0." Then
                    If Left(Text1.Text, 3) = "0.0" Then
                        If Left(Text1.Text, 4) = "0.00" Then
                            Text1.Text = "0.0" & Right(Text1.Text, 1)
                            Else
                            Text1.Text = "0." & Right(Text1.Text, 2)
                        End If
                        Else
                        Label2.Caption = Text1.Text
                        Label3.Caption = c
                        Text1.Text = Mid(Text1.Text, c - 2, 1) & "." & Right(Text1.Text, 2)
                    End If
                    Else
                    Text1.Text = Left(Text1.Text, 1) & Mid(Text1.Text, c - 2, 1) & "." & Right(Text1.Text, 2)
                End If
                Else
                Text1.Text = Left(Text1.Text, c - 4) & Mid(Text1.Text, c - 2, 1) & "." & Right(Text1.Text, 2)
            End If
        End If
    End If
    Else
End If

End Sub
2008-11-26 21:32
bccnvb6
Rank: 2
等 级:论坛游民
帖 子:28
专家分:15
注 册:2008-10-17
收藏
得分:0 
Private Sub Form_Load()
Text1.Text = "0.00"
End Sub

Private Sub Text1_Change()
Text1.SelStart = Len(Text1.Text)
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)

If KeyAscii >= 48 And KeyAscii <= 57 Then
    If Text1.Text = "0.00" Then
        Else
        If Text1.Text = "0.000" Then
            Text1.Text = "0.00"
            Else
            c = Len(Text1.Text)
            If c < 6 Then
                If Left(Text1.Text, 2) = "0." Then
                    If Left(Text1.Text, 3) = "0.0" Then
                        If Left(Text1.Text, 4) = "0.00" Then
                            Text1.Text = "0.0" & Right(Text1.Text, 1)
                            Else
                            Text1.Text = "0." & Right(Text1.Text, 2)
                        End If
                        Else
                        Label2.Caption = Text1.Text
                        Label3.Caption = c
                        Text1.Text = Mid(Text1.Text, c - 2, 1) & "." & Right(Text1.Text, 2)
                    End If
                    Else
                    Text1.Text = Left(Text1.Text, 1) & Mid(Text1.Text, c - 2, 1) & "." & Right(Text1.Text, 2)
                End If
                Else
                Text1.Text = Left(Text1.Text, c - 4) & Mid(Text1.Text, c - 2, 1) & "." & Right(Text1.Text, 2)
            End If
        End If
    End If
    Else
End If

End Sub
2008-11-26 21:37
bccnvb6
Rank: 2
等 级:论坛游民
帖 子:28
专家分:15
注 册:2008-10-17
收藏
得分:0 
Private Sub Form_Load()
Text1.Text = "0.00"
End Sub

Private Sub Text1_Change()
Text1.SelStart = Len(Text1.Text)
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)

If KeyAscii >= 48 And KeyAscii <= 57 Then
    If Text1.Text = "0.00" Then
        Else
        If Text1.Text = "0.000" Then
            Text1.Text = "0.00"
            Else
            c = Len(Text1.Text)
            If c < 6 Then
                If Left(Text1.Text, 2) = "0." Then
                    If Left(Text1.Text, 3) = "0.0" Then
                        If Left(Text1.Text, 4) = "0.00" Then
                            Text1.Text = "0.0" & Right(Text1.Text, 1)
                            Else
                            Text1.Text = "0." & Right(Text1.Text, 2)
                        End If
                        Else
                        Text1.Text = Mid(Text1.Text, c - 2, 1) & "." & Right(Text1.Text, 2)
                    End If
                    Else
                    Text1.Text = Left(Text1.Text, 1) & Mid(Text1.Text, c - 2, 1) & "." & Right(Text1.Text, 2)
                End If
                Else
                Text1.Text = Left(Text1.Text, c - 4) & Mid(Text1.Text, c - 2, 1) & "." & Right(Text1.Text, 2)
            End If
        End If
    End If
    Else
End If

End Sub
2008-11-26 21:39
逐日
Rank: 2
等 级:新手上路
威 望:5
帖 子:117
专家分:2
注 册:2008-9-22
收藏
得分:0 
谢谢,谢谢大家.虽然上面代码复制下来后运行发现有错,但已基本了解了.不过可能是我没有说清楚,我要的文本框是:
1.只能输入数字
2.小数点前可输入任意位数字,但除小数点左边第一位外首位不为0
3.小数点后是固定的小数位数,可根据需要事先定义位数

[[it] 本帖最后由 逐日 于 2008-11-27 08:19 编辑 [/it]]
2008-11-27 07:55
快速回复:下面文本框输入格式如何做到
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017316 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved