FORM1窗體代碼
Imports System.IO
Public Class Form1
    Inherits System.Windows.Forms.Form
#Region " Windows Form 設計工具產生的程式碼 "
    Public Sub New()
        MyBase.New()
        '此為 Windows Form 設計工具所需的呼叫。
        InitializeComponent()
        '在 InitializeComponent() 呼叫之後加入所有的初始設定
    End Sub
    'Form 覆寫 Dispose 以清除元件清單。
    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 Form 設計工具的必要項
    Private components As System.ComponentModel.IContainer
    '注意: 以下為 Windows Form 設計工具所需的程序
    '您可以使用 Windows Form 設計工具進行修改。
    '請勿使用程式碼編輯器來修改這些程序。
    Friend WithEvents txtName As System.Windows.Forms.TextBox
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents txtNo As System.Windows.Forms.TextBox
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents Button2 As System.Windows.Forms.Button
    Friend WithEvents Button3 As System.Windows.Forms.Button
    Friend WithEvents Button4 As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.txtName = New System.Windows.Forms.TextBox
        Me.Label1 = New System.Windows.Forms.Label
        Me.Label2 = New System.Windows.Forms.Label
        Me.txtNo = New System.Windows.Forms.TextBox
        Me.Button1 = New System.Windows.Forms.Button
        Me.Button2 = New System.Windows.Forms.Button
        Me.Button3 = New System.Windows.Forms.Button
        Me.Button4 = New System.Windows.Forms.Button
        Me.SuspendLayout()
        '
        'txtName
        '
        Me.txtName.Location = New System.Drawing.Point(88, 16)
        Me.txtName.Name = "txtName"
        Me.txtName.TabIndex = 0
        Me.txtName.Text = ""
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(8, 16)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(56, 23)
        Me.Label1.TabIndex = 1
        Me.Label1.Text = "姓名"
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(8, 72)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(56, 23)
        Me.Label2.TabIndex = 2
        Me.Label2.Text = "學號"
        '
        'txtNo
        '
        Me.txtNo.Location = New System.Drawing.Point(88, 64)
        Me.txtNo.Name = "txtNo"
        Me.txtNo.TabIndex = 3
        Me.txtNo.Text = ""
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(240, 24)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(96, 24)
        Me.Button1.TabIndex = 4
        Me.Button1.Text = "創建文件夾"
        '
        'Button2
        '
        Me.Button2.Location = New System.Drawing.Point(88, 120)
        Me.Button2.Name = "Button2"
        Me.Button2.TabIndex = 5
        Me.Button2.Text = "第一題"
        '
        'Button3
        '
        Me.Button3.Location = New System.Drawing.Point(88, 160)
        Me.Button3.Name = "Button3"
        Me.Button3.TabIndex = 6
        Me.Button3.Text = "第二題"
        '
        'Button4
        '
        Me.Button4.Location = New System.Drawing.Point(88, 200)
        Me.Button4.Name = "Button4"
        Me.Button4.TabIndex = 7
        Me.Button4.Text = "第三題"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 15)
        Me.ClientSize = New System.Drawing.Size(400, 301)
        Me.Controls.Add(Me.Button4)
        Me.Controls.Add(Me.Button3)
        Me.Controls.Add(Me.Button2)
        Me.Controls.Add(Me.Button1)
        Me.Controls.Add(Me.txtNo)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.txtName)
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)
    End Sub
#End Region
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim sDirName, strName, strNO As String
        strName = Me.txtName.Text.Trim()
        strNO = Me.txtNo.Text.Trim()
        If strName = String.Empty Or strNO = String.Empty Then
            MsgBox("姓名和學號不能為空")
            Exit Sub
        End If
        sDirName = "D:\" & strNO & "-" & strName
        Dim dDir As New DirectoryInfo(sDirName)
        If Not dDir.Exists Then '檢查該文件夾是否存在,不存在則建立
            System.IO.Directory.CreateDirectory(sDirName)
            MsgBox("創建成功")
        Else
            MsgBox("該文件夾已經存在")
        End If
    End Sub
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Text = "fairy4"
    End Sub
    Private Sub txtName_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtName.TextChanged
        Me.Text = Me.txtName.Text.Trim()
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim fm As New Form2
        fm.Show()
    End Sub
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim fm As New Form3
        fm.Show()
    End Sub
    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Dim fm As New Form4
        fm.Show()
    End Sub
End Class