Visual.Basic.NET实用编程百例-47.6M.zip

源代码在线查看: form1.vb

软件大小: 19562 K
上传用户: huanzhudev
关键词: Visual Basic 47.6 NET
下载地址: 免注册下载 普通下载 VIP

相关代码

				Imports VB = Microsoft.VisualBasic
				Friend Class Form1
					Inherits System.Windows.Forms.Form
				#Region "Windows 窗体设计器生成的代码"
					Public Sub New()
						MyBase.New()
				        '此调用是 Windows 窗体设计器所必需的。
						InitializeComponent()
					End Sub
					'窗体重写处置,以清理组件列表。
					Protected Overloads Overrides Sub Dispose(ByVal Disposing As Boolean)
						If Disposing Then
							If Not components Is Nothing Then
								components.Dispose()
							End If
						End If
						MyBase.Dispose(Disposing)
					End Sub
					'Windows 窗体设计器所必需的
					Private components As System.ComponentModel.IContainer
					Public ToolTip1 As System.Windows.Forms.ToolTip
					Public WithEvents CommonDialog1 As AxMSComDlg.AxCommonDialog
					Public WithEvents Command3 As System.Windows.Forms.Button
					Public WithEvents Command2 As System.Windows.Forms.Button
					Public WithEvents Command1 As System.Windows.Forms.Button
					Public WithEvents Text1 As System.Windows.Forms.TextBox
					Public WithEvents lstemail As System.Windows.Forms.ListBox
					Public WithEvents Label2 As System.Windows.Forms.Label
					Public WithEvents lblEmail As System.Windows.Forms.Label
					'注意: 以下过程是 Windows 窗体设计器所必需的
					'可以使用 Windows 窗体设计器来修改它。
					'不要使用代码编辑器修改它。
				    Friend WithEvents Label1 As System.Windows.Forms.Label
				     Private Sub InitializeComponent()
				        Me.components = New System.ComponentModel.Container
				        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
				        Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)
				        Me.CommonDialog1 = New AxMSComDlg.AxCommonDialog
				        Me.Command3 = New System.Windows.Forms.Button
				        Me.Command2 = New System.Windows.Forms.Button
				        Me.Command1 = New System.Windows.Forms.Button
				        Me.Text1 = New System.Windows.Forms.TextBox
				        Me.lstemail = New System.Windows.Forms.ListBox
				        Me.Label2 = New System.Windows.Forms.Label
				        Me.lblEmail = New System.Windows.Forms.Label
				        Me.Label1 = New System.Windows.Forms.Label
				        CType(Me.CommonDialog1, System.ComponentModel.ISupportInitialize).BeginInit()
				        Me.SuspendLayout()
				        '
				        'CommonDialog1
				        '
				        Me.CommonDialog1.Enabled = True
				        Me.CommonDialog1.Location = New System.Drawing.Point(4, 288)
				        Me.CommonDialog1.Name = "CommonDialog1"
				        Me.CommonDialog1.OcxState = CType(resources.GetObject("CommonDialog1.OcxState"), System.Windows.Forms.AxHost.State)
				        Me.CommonDialog1.Size = New System.Drawing.Size(32, 32)
				        Me.CommonDialog1.TabIndex = 0
				        '
				        'Command3
				        '
				        Me.Command3.BackColor = System.Drawing.SystemColors.Control
				        Me.Command3.Cursor = System.Windows.Forms.Cursors.Default
				        Me.Command3.ForeColor = System.Drawing.SystemColors.ControlText
				        Me.Command3.Location = New System.Drawing.Point(246, 290)
				        Me.Command3.Name = "Command3"
				        Me.Command3.RightToLeft = System.Windows.Forms.RightToLeft.No
				        Me.Command3.Size = New System.Drawing.Size(76, 27)
				        Me.Command3.TabIndex = 6
				        Me.Command3.Text = "保存"
				        '
				        'Command2
				        '
				        Me.Command2.BackColor = System.Drawing.SystemColors.Control
				        Me.Command2.Cursor = System.Windows.Forms.Cursors.Default
				        Me.Command2.ForeColor = System.Drawing.SystemColors.ControlText
				        Me.Command2.Location = New System.Drawing.Point(149, 290)
				        Me.Command2.Name = "Command2"
				        Me.Command2.RightToLeft = System.Windows.Forms.RightToLeft.No
				        Me.Command2.Size = New System.Drawing.Size(76, 27)
				        Me.Command2.TabIndex = 5
				        Me.Command2.Text = "整理"
				        '
				        'Command1
				        '
				        Me.Command1.BackColor = System.Drawing.SystemColors.Control
				        Me.Command1.Cursor = System.Windows.Forms.Cursors.Default
				        Me.Command1.ForeColor = System.Drawing.SystemColors.ControlText
				        Me.Command1.Location = New System.Drawing.Point(52, 290)
				        Me.Command1.Name = "Command1"
				        Me.Command1.RightToLeft = System.Windows.Forms.RightToLeft.No
				        Me.Command1.Size = New System.Drawing.Size(76, 27)
				        Me.Command1.TabIndex = 4
				        Me.Command1.Text = "提取"
				        '
				        'Text1
				        '
				        Me.Text1.AcceptsReturn = True
				        Me.Text1.AutoSize = False
				        Me.Text1.BackColor = System.Drawing.SystemColors.Window
				        Me.Text1.Cursor = System.Windows.Forms.Cursors.IBeam
				        Me.Text1.ForeColor = System.Drawing.SystemColors.WindowText
				        Me.Text1.Location = New System.Drawing.Point(8, 24)
				        Me.Text1.MaxLength = 0
				        Me.Text1.Name = "Text1"
				        Me.Text1.RightToLeft = System.Windows.Forms.RightToLeft.No
				        Me.Text1.Size = New System.Drawing.Size(317, 19)
				        Me.Text1.TabIndex = 1
				        Me.Text1.Text = ""
				        '
				        'lstemail
				        '
				        Me.lstemail.BackColor = System.Drawing.SystemColors.Window
				        Me.lstemail.Cursor = System.Windows.Forms.Cursors.Default
				        Me.lstemail.ForeColor = System.Drawing.SystemColors.WindowText
				        Me.lstemail.ItemHeight = 12
				        Me.lstemail.Location = New System.Drawing.Point(6, 56)
				        Me.lstemail.Name = "lstemail"
				        Me.lstemail.RightToLeft = System.Windows.Forms.RightToLeft.No
				        Me.lstemail.Size = New System.Drawing.Size(317, 172)
				        Me.lstemail.TabIndex = 0
				        '
				        'Label2
				        '
				        Me.Label2.AutoSize = True
				        Me.Label2.BackColor = System.Drawing.SystemColors.Control
				        Me.Label2.Cursor = System.Windows.Forms.Cursors.Default
				        Me.Label2.ForeColor = System.Drawing.SystemColors.ControlText
				        Me.Label2.Location = New System.Drawing.Point(8, 264)
				        Me.Label2.Name = "Label2"
				        Me.Label2.RightToLeft = System.Windows.Forms.RightToLeft.No
				        Me.Label2.Size = New System.Drawing.Size(0, 17)
				        Me.Label2.TabIndex = 3
				        '
				        'lblEmail
				        '
				        Me.lblEmail.AutoSize = True
				        Me.lblEmail.BackColor = System.Drawing.SystemColors.Control
				        Me.lblEmail.Cursor = System.Windows.Forms.Cursors.Default
				        Me.lblEmail.ForeColor = System.Drawing.SystemColors.ControlText
				        Me.lblEmail.Location = New System.Drawing.Point(8, 240)
				        Me.lblEmail.Name = "lblEmail"
				        Me.lblEmail.RightToLeft = System.Windows.Forms.RightToLeft.No
				        Me.lblEmail.Size = New System.Drawing.Size(0, 17)
				        Me.lblEmail.TabIndex = 2
				        '
				        'Label1
				        '
				        Me.Label1.Location = New System.Drawing.Point(8, 8)
				        Me.Label1.Name = "Label1"
				        Me.Label1.Size = New System.Drawing.Size(120, 16)
				        Me.Label1.TabIndex = 7
				        Me.Label1.Text = "保存有网页的目录"
				        '
				        'Form1
				        '
				        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
				        Me.BackColor = System.Drawing.SystemColors.Control
				        Me.ClientSize = New System.Drawing.Size(334, 326)
				        Me.Controls.Add(Me.Label1)
				        Me.Controls.Add(Me.CommonDialog1)
				        Me.Controls.Add(Me.Command3)
				        Me.Controls.Add(Me.Command2)
				        Me.Controls.Add(Me.Command1)
				        Me.Controls.Add(Me.Text1)
				        Me.Controls.Add(Me.lstemail)
				        Me.Controls.Add(Me.Label2)
				        Me.Controls.Add(Me.lblEmail)
				        Me.Cursor = System.Windows.Forms.Cursors.Default
				        Me.Location = New System.Drawing.Point(4, 23)
				        Me.Name = "Form1"
				        Me.RightToLeft = System.Windows.Forms.RightToLeft.No
				        Me.Text = "获取邮件地址"
				        CType(Me.CommonDialog1, System.ComponentModel.ISupportInitialize).EndInit()
				        Me.ResumeLayout(False)
				
				    End Sub
				#End Region 
				
					Dim St1, X, Y, St2 As Object
					Dim tmpY As Short
					
					'提取EMAIL地址子程序
					Private Sub StripEmail(ByRef FilePath As String)
						Dim tmpEmail1 As Object
						Dim tmpEmail2 As String
						FileOpen(1, FilePath, OpenMode.Input)
						Do Until EOF(1)
							On Error Resume Next
							Input(1, tmpEmail1)
							For X = 1 To Len(tmpEmail1)
				                tmpEmail2 = Mid(tmpEmail1, X, 7)
								'查找EMAIL标志
								If tmpEmail2 = "mailto:" Then
				                    St1 = X
				                    tmpY = X + 1
									For Y = 1 To Len(tmpEmail1)
				                        tmpEmail2 = Mid(tmpEmail1, tmpY, 1)
										If tmpEmail2 = Chr(34) Or tmpEmail2 = "?" Then
				                            St2 = tmpY
				                            tmpEmail2 = Mid(tmpEmail1, St1 + 7, (St2 - St1) - 7)
											If (VB.Left(tmpEmail2, 2)  "//") And (VB.Left(tmpEmail2, 1)  " ") Then
												lstemail.Items.Add(tmpEmail2)
												Exit For
											End If
										End If
										tmpY = tmpY + 1
									Next Y
								End If
							Next X
						Loop 
						FileClose(1)
					End Sub
					
					Private Sub Command1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command1.Click
						Dim fs As New Scripting.FileSystemObject ' 建立 FileSystemObject
						Dim fd As Scripting.Folder ' 定义 Folder 对象
						Dim sfd As Scripting.Folder
						fd = fs.GetFolder(Text1.Text)
						Command1.Enabled = False
				        System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor
						FindFile(fd, "*.htm") 'Text1.Text
						Command1.Enabled = True
				        System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default
					End Sub
					
					Sub FindFile(ByRef fd As Scripting.Folder, ByRef FileName As String)
						Dim sfd As Scripting.Folder
						Dim f As Scripting.File
						' Part I			

相关资源