以下是程式碼…但我的TextBox是動態增加的…
'加上這一行
Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click
'Dim ThisObj As Object
Dim LB1 As New Label
'這一行刪除
Dim Btn1 As New Button
'加上這一行
Controls.Clear()
Me.Controls.Add(LB1)
Me.Controls.Add(TB1)
With LB1
.Left = 10
.Top = 11
.Text = "請選擇檔案"
.Font = New Font("標楷體", 12)
End With
With TB1
.Height = 30
.Width = 220
.Left = 110
.Top = 10
.Name = "FileFullName"
End With
Me.Controls.Add(Btn1)
With Btn1
.Top = 10
.Left = 400
.Width = 80
.Font = New Font("標楷體", 12)
.Text = "選擇檔案"
End With
AddHandler Btn1.Click, AddressOf Btn1_Click
End Sub
Private Sub Btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim OPform As New System.Windows.Forms.OpenFileDialog
OPform.Multiselect = False
OPform.ShowDialog()
| TB1.Text = OPform.FileName |
'加上這一行
End Sub