文件名称:文本阅读器
文件大小:52KB
文件格式:RAR
更新时间:2015-06-25 04:33:39
vb
Dim n As Integer, Lines As Integer, i As Integer, w As Integer, a As Boolean Private Sub Command1_Click() Command6.Visible = False a = Not a '变量开关,再次打开文件时进行判断 If a = True Then no1: Dim infile As String '打开通用对话框,获取文件名称 CommonDialog1.InitDir = "" CommonDialog1.Filter = "文本文件(*.txt)|*.txt|所有文件(*.*)|*.*" CommonDialog1.FilterIndex = 1 CommonDialog1.ShowOpen infile = CommonDialog1.FileName Dim txt() As String, Lines As Integer Lines = 0 ' 文件行数总计 Open infile For Input As #1 'infile 变量中存放的是文本文件的名字 While Not EOF(1) ReDim Preserve txt(Lines + 1) '开辟空间以存放一行内容 Lines = Lines + 1 Line Input #1, txt(Lines) '读入一行并放入数组 Wend w = Lines Close #1 '关闭文件 Label1(1) = txt(1) Label1(1).Top = Command1.Height Label1(1).Left = 0 Label1(1).Width = Form1.Width '加载label控件数组并读入文本 For n = 2 To Lines Load Label1(n) 'Form1.width = Label1(n).width Label1(n).Left = 0 Label1(n).AutoSize = True Label1(n).WordWrap = True Label1(n).Width = Form1.Width Label1(n).Caption = txt(n) Label1(n).Visible = True Label1(n).Top = Label1(n - 1).Height + Label1(n - 1).Top Label1(n).Left = Label1(1).Left Next Else Call Command6_Click a = Not a GoTo no1 End If End Sub Private Sub Command2_Click() '减少interval Timer1.Interval = Timer1.Interval - 25 End Sub Private Sub Command3_Click() '增加interval Timer1.Interval = Timer1.Interval + 30 End Sub Private Sub Command4_Click() '打开“字体”对话框 CommonDialog1.Flags = cdlCFBoth Or cdlCFEffects On Error GoTo errhandler CommonDialog1.ShowFont '设置label1控件数组内容的属性 For i = 1 To w Label1(i).FontName = CommonDialog1.FontName Label1(i).FontBold = CommonDialog1.FontBold Label1(i).FontItalic = CommonDialog1.FontItalic Label1(i).FontSize = CommonDialog1.FontSize Label1(i).FontStrikethru = CommonDialog1.FontStrikethru Label1(i).FontUnderline = CommonDialog1.FontUnderline Label1(i).ForeColor = CommonDialog1.Color Label1(i).AutoSize = True Label1(i).WordWrap = True '根据label1控件数组的大小进行重新排列 For n = 2 To w Label1(n).Top = Label1(n - 1).Top + Label1(n - 1).Height Next Next errhandler: Exit Sub End Sub Private Sub Command5_Click() End End Sub Private Sub Command6_Click() Command6.Visible = False '再次打开文件时卸载label1控件数组 For n = 2 To w Unload Label1(n) Next End Sub Private Sub Command7_Click() '从头显示文件内容 Label1(1).Top = Command1.Height For i = 2 To w Label1(i).Top = Label1(i - 1).Top + Label1(i - 1).Height Next End Sub Private Sub Form_Load() Timer1.Interval = 300 End Sub Private Sub Label1_Click(Index As Integer) '控制滚屏,及命令按钮的隐现 Timer1.Enabled = Not Timer1.Enabled Command1.Visible = Not Timer1.Enabled Command2.Visible = Not Timer1.Enabled Command3.Visible = Not Timer1.Enabled Command4.Visible = Not Timer1.Enabled Command5.Visible = Not Timer1.Enabled Command7.Visible = Not Timer1.Enabled End Sub Private Sub Timer1_Timer() For i = 1 To w Label1(i).Top = Label1(i).Top - 90 Next '到达文件尾自动停止滚屏并显示命令按钮 If Label1(w).Top + Label1(w).Height < Form1.Height - 400 Then Timer1.Enabled = False Command1.Visible = True Command2.Visible = True Command3.Visible = True Command4.Visible = True Command5.Visible = True Command7.Visible = True MsgBox "文章已经到头" End If End Sub 做vb
【文件预览】:
08文本阅读器
----MSSCCPRJ.SCC(337B)
----XUYINS~1.LOG(241B)
----XUYINSONG.vbw(49B)
----XYS()
--------自动文本阅读器.doc(30KB)
--------工程1.vbp(723B)
--------MSSCCPRJ.SCC(337B)
--------XUYINSONG.vbp(728B)
--------43-自动文本阅读器任务书.doc(65KB)
--------B.TXT(3KB)
--------XUYINSONG.vbw(51B)
--------XUYINSONG.frm(6KB)
--------工程1.vbw(49B)
--------XUYINSONG.log(79B)
--------A.TXT(5KB)
--------XUYINS~1 (2).log(241B)