vb自动增加编号从0000到9999

来源:百度知道 编辑:UC知道 时间:2024/05/19 15:26:45
vb自动增加编号从0000到9999
我要实现,每点击一下command 控件,自动编号增加1,然在text显示此时的编号,随着点击次数的增加而在text显示的值也增加。
请大家帮忙!
即:开头的text=0000
command 点击第1次 0001
command 点击第2次 0002
command 点击第3次 0003

Private Sub Command1_Click()
Dim StrV As String
Dim IntRight As Integer

If Trim(Text1.Text) = "" Then
IntRight = 0
Else
IntRight = CInt(Text1.Text)
End If
IntRight = IntRight + 1
Select Case Len(CStr(IntRight))
Case Is = 1
StrV = "000" & CStr(IntRight)
Case Is = 2
StrV = "00" & CStr(IntRight)
Case Is = 3
StrV = "0" & CStr(IntRight)
Case Is = 4
StrV = CStr(IntRight)
End Select
If Len(Trim(StrV)) > 4 Then Exit Sub
Text1.Text = StrV
End Sub

Private Sub Form_Load()
Text1.Text = ""
End Sub

抢分走人

可以
在command1_click中编写
static a as integer
a=a+1
a = 9999
b = Format(a, "000#")
Print b

这个是最简单的
把值传到TEXT不用我说了吧
实在不可以的话再HI我吧

dim i as long

'-------------------------
sub command1_click
i=i+1
text1=format(