VB怎么写如下程序代码
像春节联欢晚会一样,快速显示11位手机号码,越来越快地显示,你一点停止,却是慢慢地停下来.求实现如上功能的代码!你可以随机取数啊.比如说01到100...
像春节联欢晚会一样,快速显示11位手机号码,越来越快地显示,你一点停止,却是慢慢地停下来.求实现如上功能的代码!
你可以随机取数啊.比如说01到100 展开
你可以随机取数啊.比如说01到100 展开
展开全部
加一个T时间控件,Timer1一个文件框Text1一个按键command1
Private Sub Command1_Click()
If Command1.Caption = "开始" Then
Text1.ForeColor = vbBlack
Command1.Caption = "停止"
Timer1.Enabled = True
Else
Command1.Caption = "开始"
End If
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 500
Command1.Caption = "开始"
End Sub
Private Sub Timer1_Timer()
Randomize 这是初始化的意思
i = Rnd * 1000000000#
Text1 = "1" & "3" & Mid(Fix(i), 1, 9)
If Command1.Caption = "停止" Then
If Timer1.Interval = 50 Then Exit Sub
Timer1.Interval = Val(Timer1.Interval - 50)
Else
Timer1.Interval = Val(Timer1.Interval + 50)
If Timer1.Interval > 500 Then
Timer1.Enabled = False
Text1.ForeColor = vbRed
End If
End If
End Sub
Private Sub Command1_Click()
If Command1.Caption = "开始" Then
Text1.ForeColor = vbBlack
Command1.Caption = "停止"
Timer1.Enabled = True
Else
Command1.Caption = "开始"
End If
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 500
Command1.Caption = "开始"
End Sub
Private Sub Timer1_Timer()
Randomize 这是初始化的意思
i = Rnd * 1000000000#
Text1 = "1" & "3" & Mid(Fix(i), 1, 9)
If Command1.Caption = "停止" Then
If Timer1.Interval = 50 Then Exit Sub
Timer1.Interval = Val(Timer1.Interval - 50)
Else
Timer1.Interval = Val(Timer1.Interval + 50)
If Timer1.Interval > 500 Then
Timer1.Enabled = False
Text1.ForeColor = vbRed
End If
End If
End Sub
展开全部
需要连接记录有手机号的数据库 否则白说
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你是不是要随机的抽取号码啊?
试试这个吧~
建立两个Timer控件,Timer1和Timer2;一个文件框控件Text1;一个按钮控件Command1.
Command1的Caption属性设置为"开始".
Timer1的Interval属性设置为1,Enabled属性为False;Timer2的Interval属性设置为500,Enabled属性为False.
Option Base 1
Dim Num(11) As Integer
Private Sub Command1_Click()
If Command1.Caption = "开始" Then '启动Timer1,开始取号码
Command1.Caption = "停止"
Timer1.Enabled = True
Else'停止取号码
Command1.Caption = "开始"
Timer2.Enabled = True 'Timer2控制号码的变化慢慢变慢直至停止
End If
End Sub
Private Sub Timer1_Timer()
Randomize '重置随机种子
Text1.Text = ""
Num(1) = 1 '这里只取13开头的号码,159的没有加进去,LZ自己试试吧~
Num(2) = 3
For a = 3 To 11 '给其它号码位取号码
Num(a) = (9 - 0 + 1) * Rnd + 0
If Num(a) > 9 Then Num(a) = 0
Next a
For b = 1 To 11
Text1.Text = Text1.Text & Num(b) 'Text1显示号码
Next b
End Sub
Private Sub Timer2_Timer() '让Timer1的周期慢下来
Timer1.Interval = Timer1.Interval + 100
If Timer1.Interval > 1000 Then
Timer1.Enabled = False
Timer1.Interval = 1
Msgbox "选中的号码为 " & Text1.Text
Timer2.Enabled = False
End If
End Sub
试试这个吧~
建立两个Timer控件,Timer1和Timer2;一个文件框控件Text1;一个按钮控件Command1.
Command1的Caption属性设置为"开始".
Timer1的Interval属性设置为1,Enabled属性为False;Timer2的Interval属性设置为500,Enabled属性为False.
Option Base 1
Dim Num(11) As Integer
Private Sub Command1_Click()
If Command1.Caption = "开始" Then '启动Timer1,开始取号码
Command1.Caption = "停止"
Timer1.Enabled = True
Else'停止取号码
Command1.Caption = "开始"
Timer2.Enabled = True 'Timer2控制号码的变化慢慢变慢直至停止
End If
End Sub
Private Sub Timer1_Timer()
Randomize '重置随机种子
Text1.Text = ""
Num(1) = 1 '这里只取13开头的号码,159的没有加进去,LZ自己试试吧~
Num(2) = 3
For a = 3 To 11 '给其它号码位取号码
Num(a) = (9 - 0 + 1) * Rnd + 0
If Num(a) > 9 Then Num(a) = 0
Next a
For b = 1 To 11
Text1.Text = Text1.Text & Num(b) 'Text1显示号码
Next b
End Sub
Private Sub Timer2_Timer() '让Timer1的周期慢下来
Timer1.Interval = Timer1.Interval + 100
If Timer1.Interval > 1000 Then
Timer1.Enabled = False
Timer1.Interval = 1
Msgbox "选中的号码为 " & Text1.Text
Timer2.Enabled = False
End If
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Option Explicit
Dim f As Integer
Private Sub Command1_Click()
f = 1
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Randomize
If Timer1.Interval <= 100 Then f = 0
If f = 1 Then
Timer1.Interval = Timer1.Interval - 50
Else
Timer1.Interval = Timer1.Interval + 50
End If
Label1.Caption = CInt(Rnd * (100))
If Timer1.Interval > 1000 And f = 0 Then
Timer1.Enabled = False
MsgBox Label1.Caption
End If
End Sub
加1个Timer,1个COMMAND,1个label
Dim f As Integer
Private Sub Command1_Click()
f = 1
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Randomize
If Timer1.Interval <= 100 Then f = 0
If f = 1 Then
Timer1.Interval = Timer1.Interval - 50
Else
Timer1.Interval = Timer1.Interval + 50
End If
Label1.Caption = CInt(Rnd * (100))
If Timer1.Interval > 1000 And f = 0 Then
Timer1.Enabled = False
MsgBox Label1.Caption
End If
End Sub
加1个Timer,1个COMMAND,1个label
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询