实例介绍
【实例简介】随机抽取编号
【实例截图】
【核心代码】Dim BuChang As Single
Private Sub Command1_Click()
Me.List1.Clear
For i = Val(Me.Text5(6).Text) To Val(Me.Text5(7).Text)
Me.List1.AddItem "A" & Format(i, "000")
Next
For i = Val(Me.Text5(6).Text) To Val(Me.Text5(7).Text)
Me.List1.AddItem "B" & Format(i, "000")
Next
For i = Val(Me.Text5(6).Text) To Val(Me.Text5(7).Text)
Me.List1.AddItem "C" & Format(i, "000")
Next
For i = Val(Me.Text5(6).Text) To Val(Me.Text5(7).Text)
Me.List1.AddItem "D" & Format(i, "000")
Next
For i = Val(Me.Text5(6).Text) To Val(Me.Text5(7).Text)
Me.List1.AddItem "E" & Format(i, "000")
Next
For i = Val(Me.Text5(6).Text) To Val(Me.Text5(7).Text)
Me.List1.AddItem "F" & Format(i, "000")
Next
End Sub
Private Sub Command2_Click()
Form2.Label1.Caption = ""
Form2.Image1.Picture = LoadPicture(App.Path & "\底.jpg")
Form2.ZOrder 1
Form2.Label1.FontBold = Me.Text5(4).FontBold
Form2.Label1.FontItalic = Me.Text5(4).FontItalic
Form2.Label1.FontName = Me.Text5(4).FontName
Form2.Label1.FontSize = Val(Me.Text5(5).Text)
Form2.Show
Form2.Left = Val(Me.Text5(8).Text) * 15
End Sub
Private Sub Command3_Click()
Me.Timer1.Enabled = True
End Sub
Private Sub Command4_Click()
Me.Timer1.Enabled = False
If Me.Check1.Value Then
Form2.Label1.Caption = Me.Text1.Text
End If
For i = 0 To Me.List1.ListCount - 1
If Form2.Label1.Caption = Me.List1.List(i) Then
Me.List1.RemoveItem i
End If
Next
End Sub
Private Sub Command5_Click()
Form2.PrintForm
End Sub
Private Sub Command6_Click()
For i = 0 To Me.List1.ListCount
If Me.Text3.Text = Me.List1.List(i) Then
GoTo Gs:
End If
Next
Me.List1.AddItem Me.Text3.Text
Gs:
End Sub
Private Sub Form_Load()
Me.List1.Clear
For i = Val(Me.Text5(6).Text) To Val(Me.Text5(7).Text)
Me.List1.AddItem "A" & Format(i, "000")
Next
For i = Val(Me.Text5(6).Text) To Val(Me.Text5(7).Text)
Me.List1.AddItem "B" & Format(i, "000")
Next
For i = Val(Me.Text5(6).Text) To Val(Me.Text5(7).Text)
Me.List1.AddItem "C" & Format(i, "000")
Next
For i = Val(Me.Text5(6).Text) To Val(Me.Text5(7).Text)
Me.List1.AddItem "D" & Format(i, "000")
Next
For i = Val(Me.Text5(6).Text) To Val(Me.Text5(7).Text)
Me.List1.AddItem "E" & Format(i, "000")
Next
For i = Val(Me.Text5(6).Text) To Val(Me.Text5(7).Text)
Me.List1.AddItem "F" & Format(i, "000")
Next
Me.Timer2.Enabled = True
load_weninf
End Sub
Private Sub Form_Unload(Cancel As Integer)
Save_weizhi
Unload Form1
Unload Form2
End
End Sub
Sub load_weninf()
Dim fs, file
On Error Resume Next
Set fs = CreateObject("Scripting.FileSystemObject")
Set file = fs.openTextFile(App.Path & "\data.ini")
For i = 0 To 8
Me.Text5(i).Text = file.readline
Next
If file.readline = "true" Then
Me.Text5(4).FontBold = True
Else
Me.Text5(4).FontBold = False
End If
If file.readline = "true" Then
Me.Text5(4).FontItalic = True
Else
Me.Text5(4).FontItalic = False
End If
Me.Text5(4).FontName = file.readline
Me.Text5(4).Text = Me.Text5(4).FontName
Me.Text2.Text = file.readline
End Sub
Sub Save_weizhi()
On Error Resume Next
Dim fs, file
Set fs = CreateObject("Scripting.FileSystemObject")
Set file = fs.createtextfile(App.Path & "\data.ini")
' file.writeline Me.Text1.Text
For i = 0 To 8
file.writeline Me.Text5(i).Text
Next
If Me.Text5(4).FontBold = True Then
file.writeline "true"
Else
file.writeline "false"
End If
If Me.Text5(4).FontItalic = True Then
file.writeline "true"
Else
file.writeline "false"
End If
file.writeline Me.Text5(4).FontName
file.writeline Me.Text2.Text
End Sub
Private Sub Text6_Change(Index As Integer)
End Sub
Private Sub List1_Click()
Me.List1.RemoveItem Me.List1.ListIndex
End Sub
Private Sub Text2_Change()
Form2.Label2.Caption = Me.Text2.Text
End Sub
Private Sub Text5_Change(Index As Integer)
On Error Resume Next
Select Case Index
Case 0
Form2.Width = Val(Me.Text5(0).Text) * 15
Form2.Label1.Width = Form2.Width
Form2.Image1.Width = Form2.Width
Case 1
Form2.Height = Val(Me.Text5(1).Text) * 15
Form2.Image1.Height = Form2.Height
Case 2
Form2.Label1.Top = Val(Me.Text5(2).Text) * 15
Case 5
Form2.Label1.FontSize = Val(Me.Text5(5).Text)
Case 3
Me.Text5(3).ForeColor = Val(Me.Text5(3).Text)
Form2.Label1.ForeColor = Val(Me.Text5(3).Text)
Case 6, 7
Me.List1.Clear
For i = Val(Me.Text5(6).Text) To Val(Me.Text5(7).Text)
Me.List1.AddItem i
Next
End Select
Form2.Label2.Width = Form2.Width - 120
Form2.Label3.Width = Form2.Width - 120
Form2.Label2.Top = Form2.Height - 360
Form2.Label2.Left = 0
Form2.Label3.Top = Form2.Height - 690
Form2.Label3.Left = 0
End Sub
Private Sub Text5_DblClick(Index As Integer)
On Error Resume Next
Select Case Index
Case 4, 5
Me.CommonDialog1.FontBold = Me.Text5(4).FontBold
Me.CommonDialog1.FontItalic = Me.Text5(4).FontItalic
Me.CommonDialog1.FontName = Me.Text5(4).FontName
Me.CommonDialog1.FontSize = Val(Me.Text5(5).Text)
Me.CommonDialog1.ShowFont
Me.Text5(4).FontBold = Me.CommonDialog1.FontBold
Me.Text5(4).FontItalic = Me.CommonDialog1.FontItalic
Me.Text5(4).Text = Me.CommonDialog1.FontName
Me.Text5(4).FontName = Me.CommonDialog1.FontName
Me.Text5(5).Text = Me.CommonDialog1.FontSize
Form2.Label1.FontBold = Me.Text5(4).FontBold
Form2.Label1.FontItalic = Me.Text5(4).FontItalic
Form2.Label1.FontName = Me.Text5(4).FontName
Form2.Label1.FontSize = Val(Me.Text5(5).Text)
Case 3
Me.CommonDialog1.Color = Me.Text5(3).ForeColor
Me.CommonDialog1.ShowColor
Me.Text5(3).ForeColor = Me.CommonDialog1.Color
Me.Text5(3).Text = Me.CommonDialog1.Color
Form2.Label1.ForeColor = Me.CommonDialog1.Color
End Select
End Sub
Private Sub Timer1_Timer()
Form2.Label1.Caption = Me.List1.List(Int(Rnd() * Me.List1.ListCount))
End Sub
Private Sub Timer2_Timer()
Form2.Label3.Caption = Date
End Sub
【实例截图】

【核心代码】Dim BuChang As Single
Private Sub Command1_Click()
Me.List1.Clear
For i = Val(Me.Text5(6).Text) To Val(Me.Text5(7).Text)
Me.List1.AddItem "A" & Format(i, "000")
Next
For i = Val(Me.Text5(6).Text) To Val(Me.Text5(7).Text)
Me.List1.AddItem "B" & Format(i, "000")
Next
For i = Val(Me.Text5(6).Text) To Val(Me.Text5(7).Text)
Me.List1.AddItem "C" & Format(i, "000")
Next
For i = Val(Me.Text5(6).Text) To Val(Me.Text5(7).Text)
Me.List1.AddItem "D" & Format(i, "000")
Next
For i = Val(Me.Text5(6).Text) To Val(Me.Text5(7).Text)
Me.List1.AddItem "E" & Format(i, "000")
Next
For i = Val(Me.Text5(6).Text) To Val(Me.Text5(7).Text)
Me.List1.AddItem "F" & Format(i, "000")
Next
End Sub
Private Sub Command2_Click()
Form2.Label1.Caption = ""
Form2.Image1.Picture = LoadPicture(App.Path & "\底.jpg")
Form2.ZOrder 1
Form2.Label1.FontBold = Me.Text5(4).FontBold
Form2.Label1.FontItalic = Me.Text5(4).FontItalic
Form2.Label1.FontName = Me.Text5(4).FontName
Form2.Label1.FontSize = Val(Me.Text5(5).Text)
Form2.Show
Form2.Left = Val(Me.Text5(8).Text) * 15
End Sub
Private Sub Command3_Click()
Me.Timer1.Enabled = True
End Sub
Private Sub Command4_Click()
Me.Timer1.Enabled = False
If Me.Check1.Value Then
Form2.Label1.Caption = Me.Text1.Text
End If
For i = 0 To Me.List1.ListCount - 1
If Form2.Label1.Caption = Me.List1.List(i) Then
Me.List1.RemoveItem i
End If
Next
End Sub
Private Sub Command5_Click()
Form2.PrintForm
End Sub
Private Sub Command6_Click()
For i = 0 To Me.List1.ListCount
If Me.Text3.Text = Me.List1.List(i) Then
GoTo Gs:
End If
Next
Me.List1.AddItem Me.Text3.Text
Gs:
End Sub
Private Sub Form_Load()
Me.List1.Clear
For i = Val(Me.Text5(6).Text) To Val(Me.Text5(7).Text)
Me.List1.AddItem "A" & Format(i, "000")
Next
For i = Val(Me.Text5(6).Text) To Val(Me.Text5(7).Text)
Me.List1.AddItem "B" & Format(i, "000")
Next
For i = Val(Me.Text5(6).Text) To Val(Me.Text5(7).Text)
Me.List1.AddItem "C" & Format(i, "000")
Next
For i = Val(Me.Text5(6).Text) To Val(Me.Text5(7).Text)
Me.List1.AddItem "D" & Format(i, "000")
Next
For i = Val(Me.Text5(6).Text) To Val(Me.Text5(7).Text)
Me.List1.AddItem "E" & Format(i, "000")
Next
For i = Val(Me.Text5(6).Text) To Val(Me.Text5(7).Text)
Me.List1.AddItem "F" & Format(i, "000")
Next
Me.Timer2.Enabled = True
load_weninf
End Sub
Private Sub Form_Unload(Cancel As Integer)
Save_weizhi
Unload Form1
Unload Form2
End
End Sub
Sub load_weninf()
Dim fs, file
On Error Resume Next
Set fs = CreateObject("Scripting.FileSystemObject")
Set file = fs.openTextFile(App.Path & "\data.ini")
For i = 0 To 8
Me.Text5(i).Text = file.readline
Next
If file.readline = "true" Then
Me.Text5(4).FontBold = True
Else
Me.Text5(4).FontBold = False
End If
If file.readline = "true" Then
Me.Text5(4).FontItalic = True
Else
Me.Text5(4).FontItalic = False
End If
Me.Text5(4).FontName = file.readline
Me.Text5(4).Text = Me.Text5(4).FontName
Me.Text2.Text = file.readline
End Sub
Sub Save_weizhi()
On Error Resume Next
Dim fs, file
Set fs = CreateObject("Scripting.FileSystemObject")
Set file = fs.createtextfile(App.Path & "\data.ini")
' file.writeline Me.Text1.Text
For i = 0 To 8
file.writeline Me.Text5(i).Text
Next
If Me.Text5(4).FontBold = True Then
file.writeline "true"
Else
file.writeline "false"
End If
If Me.Text5(4).FontItalic = True Then
file.writeline "true"
Else
file.writeline "false"
End If
file.writeline Me.Text5(4).FontName
file.writeline Me.Text2.Text
End Sub
Private Sub Text6_Change(Index As Integer)
End Sub
Private Sub List1_Click()
Me.List1.RemoveItem Me.List1.ListIndex
End Sub
Private Sub Text2_Change()
Form2.Label2.Caption = Me.Text2.Text
End Sub
Private Sub Text5_Change(Index As Integer)
On Error Resume Next
Select Case Index
Case 0
Form2.Width = Val(Me.Text5(0).Text) * 15
Form2.Label1.Width = Form2.Width
Form2.Image1.Width = Form2.Width
Case 1
Form2.Height = Val(Me.Text5(1).Text) * 15
Form2.Image1.Height = Form2.Height
Case 2
Form2.Label1.Top = Val(Me.Text5(2).Text) * 15
Case 5
Form2.Label1.FontSize = Val(Me.Text5(5).Text)
Case 3
Me.Text5(3).ForeColor = Val(Me.Text5(3).Text)
Form2.Label1.ForeColor = Val(Me.Text5(3).Text)
Case 6, 7
Me.List1.Clear
For i = Val(Me.Text5(6).Text) To Val(Me.Text5(7).Text)
Me.List1.AddItem i
Next
End Select
Form2.Label2.Width = Form2.Width - 120
Form2.Label3.Width = Form2.Width - 120
Form2.Label2.Top = Form2.Height - 360
Form2.Label2.Left = 0
Form2.Label3.Top = Form2.Height - 690
Form2.Label3.Left = 0
End Sub
Private Sub Text5_DblClick(Index As Integer)
On Error Resume Next
Select Case Index
Case 4, 5
Me.CommonDialog1.FontBold = Me.Text5(4).FontBold
Me.CommonDialog1.FontItalic = Me.Text5(4).FontItalic
Me.CommonDialog1.FontName = Me.Text5(4).FontName
Me.CommonDialog1.FontSize = Val(Me.Text5(5).Text)
Me.CommonDialog1.ShowFont
Me.Text5(4).FontBold = Me.CommonDialog1.FontBold
Me.Text5(4).FontItalic = Me.CommonDialog1.FontItalic
Me.Text5(4).Text = Me.CommonDialog1.FontName
Me.Text5(4).FontName = Me.CommonDialog1.FontName
Me.Text5(5).Text = Me.CommonDialog1.FontSize
Form2.Label1.FontBold = Me.Text5(4).FontBold
Form2.Label1.FontItalic = Me.Text5(4).FontItalic
Form2.Label1.FontName = Me.Text5(4).FontName
Form2.Label1.FontSize = Val(Me.Text5(5).Text)
Case 3
Me.CommonDialog1.Color = Me.Text5(3).ForeColor
Me.CommonDialog1.ShowColor
Me.Text5(3).ForeColor = Me.CommonDialog1.Color
Me.Text5(3).Text = Me.CommonDialog1.Color
Form2.Label1.ForeColor = Me.CommonDialog1.Color
End Select
End Sub
Private Sub Timer1_Timer()
Form2.Label1.Caption = Me.List1.List(Int(Rnd() * Me.List1.ListCount))
End Sub
Private Sub Timer2_Timer()
Form2.Label3.Caption = Date
End Sub
好例子网口号:伸出你的我的手 — 分享!
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论