要求从一个文本文件中读入身份证号码,然后在表单上循环快速显示,这时按下回车,或者单击鼠标,停止号码循环显示,并在表单下边显示选出的号码。要求程序中要有详尽的注释,这一点很重要,因为以后本人可能要改动!
最后说一句:本人一定给分,先在这里谢谢各位了!
最后说一句:本人一定给分,先在这里谢谢各位了!
解决方案 »
- VB程序如何“这样”访问共享
- EXCEL2007如何另存为2003以前版本的EXCEL文件???(.xlsx->.xls)
- [求助]有关变量传递中的设置问题!
- 如何将chm和vb连接
- 如何提高LISTVIEW的刷新速度
- vb adodc1添加删除更新代码怎么写啊
- 去掉快捷方式的箭头
- 请问用VB6如何动态的设置ODBC ?
- 天那!学了2年的VB,连这个问题也没搞懂!!!!
- 在使用vb.net-acess通过dataAdapter对象的insertcommand属性向数据库中添加纪录时出现字符串语法错误的提示,求解答!!
- 如何用VB对输出到EXCEL97报表中的数值型字段进行分类小计和汇总。
- 小弟请教各位大虾一个数据库的问题
220111345678910
110214578412412
330124787451210
658745124784121
958741257485214把以下代码保存为form1.frm,用VB打开即可VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 2160
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 2160
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command2
Caption = "Start"
Height = 495
Left = 1200
TabIndex = 2
Top = 1440
Width = 1215
End
Begin VB.Timer Timer1
Enabled = 0 'False
Interval = 100
Left = 720
Top = 1440
End
Begin VB.TextBox Text1
Height = 615
Left = 600
TabIndex = 1
Text = "Text1"
Top = 480
Width = 3375
End
Begin VB.CommandButton Command1
Caption = "Stop"
Height = 495
Left = 2520
TabIndex = 0
Top = 1440
Width = 1215
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim DataArray() As String
Dim k As Long
Private Sub Command1_Click()
Timer1.Enabled = False
End SubPrivate Sub Command2_Click()
Timer1.Enabled = True
End SubPrivate Sub Form_Load()
LoadData
End SubPrivate Sub Timer1_Timer()Randomize
k = Int((UBound(DataArray) - 1 + 1) * Rnd + 1)
Text1.Text = DataArray(k)End Sub
Sub LoadData()
Dim i As Long, j As Long
Dim ReadData As String
Open App.Path + "\data.txt" For Input As #1
dd: Do Until EOF(1)
Line Input #1, ReadData
If ReadData = "" Then
GoTo dd
End If
i = i + 1
Loop
Close #1
ReDim DataArray(i)
Open App.Path + "\data.txt" For Input As #1
bb: Do Until EOF(1)
Line Input #1, ReadData
If ReadData = "" Then
GoTo bb
End If
DataArray(j) = ReadData
j = j + 1
Loop
Close #1End Sub
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3615
ClientLeft = 60
ClientTop = 345
ClientWidth = 5250
LinkTopic = "Form1"
ScaleHeight = 3615
ScaleWidth = 5250
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command2
Caption = "Start"
Height = 495
Left = 1200
TabIndex = 2
Top = 1440
Width = 1215
End
Begin VB.Timer Timer1
Enabled = 0 'False
Interval = 100
Left = 720
Top = 1440
End
Begin VB.TextBox Text1
Height = 615
Left = 600
TabIndex = 1
Text = "Text1"
Top = 480
Width = 3375
End
Begin VB.CommandButton Command1
Caption = "Stop"
Height = 495
Left = 2520
TabIndex = 0
Top = 1440
Width = 1215
End
Begin VB.Label Label1
Caption = "Label1"
Height = 495
Left = 120
TabIndex = 3
Top = 0
Width = 4335
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim DataArray() As String
Dim k As Long
Private Sub Command1_Click()
Timer1.Enabled = False
End SubPrivate Sub Command2_Click()
Timer1.Enabled = True
End SubPrivate Sub Form_Load()
LoadData
End SubPrivate Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Timer1.Enabled = False
Label1.Caption = Text1.Text
End If
End SubPrivate Sub Label1_Click()End SubPrivate Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Timer1.Enabled = False
Label1.Caption = Text1.Text
End If
End SubPrivate Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Timer1.Enabled = False
Label1.Caption = Text1.Text
End If
End SubPrivate Sub Timer1_Timer()Randomize
k = Int((UBound(DataArray) - 1 + 1) * Rnd + 1)
Text1.Text = DataArray(k)End Sub
Sub LoadData()
Dim i As Long, j As Long
Dim ReadData As String
Open App.Path + "\data.txt" For Input As #1
dd: Do Until EOF(1)
Line Input #1, ReadData
If ReadData = "" Then
GoTo dd
End If
i = i + 1
Loop
Close #1
ReDim DataArray(i)
Open App.Path + "\data.txt" For Input As #1
bb: Do Until EOF(1)
Line Input #1, ReadData
If ReadData = "" Then
GoTo bb
End If
DataArray(j) = ReadData
j = j + 1
Loop
Close #1End Sub
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3615
ClientLeft = 60
ClientTop = 345
ClientWidth = 5250
LinkTopic = "Form1"
ScaleHeight = 3615
ScaleWidth = 5250
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command2
Caption = "Start"
Height = 495
Left = 1200
TabIndex = 2
Top = 1440
Width = 1215
End
Begin VB.Timer Timer1
Enabled = 0 'False
Interval = 100
Left = 720
Top = 1440
End
Begin VB.TextBox Text1
Height = 615
Left = 600
TabIndex = 1
Text = "Text1"
Top = 480
Width = 3375
End
Begin VB.CommandButton Command1
Caption = "Stop"
Height = 495
Left = 2520
TabIndex = 0
Top = 1440
Width = 1215
End
Begin VB.Label Label1
Caption = "号码为:"
Height = 495
Left = 240
TabIndex = 3
Top = 2400
Width = 4335
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim DataArray() As String
Dim k As Long
Private Sub Command1_Click()
Timer1.Enabled = False
Label1 = "号码为:" & Text1.Text
End SubPrivate Sub Command2_Click()
Timer1.Enabled = True
End SubPrivate Sub Form_Load()
LoadData
End SubPrivate Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Timer1.Enabled = False
Label1 = "号码为:" & Text1.Text
End If
End SubPrivate Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Timer1.Enabled = False
Label1.Caption = Text1.Text
End If
End SubPrivate Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Timer1.Enabled = False
Label1.Caption = Text1.Text
End If
End SubPrivate Sub Timer1_Timer()Randomize
k = Int((UBound(DataArray) - 1 + 1) * Rnd + 1)
Text1.Text = DataArray(k)End Sub
Sub LoadData()
Dim i As Long, j As Long
Dim ReadData As String
Open App.Path + "\data.txt" For Input As #1
dd: Do Until EOF(1)
Line Input #1, ReadData
If ReadData = "" Then
GoTo dd
End If
i = i + 1
Loop
Close #1
ReDim DataArray(i)
Open App.Path + "\data.txt" For Input As #1
bb: Do Until EOF(1)
Line Input #1, ReadData
If ReadData = "" Then
GoTo bb
End If
DataArray(j) = ReadData
j = j + 1
Loop
Close #1End Sub