First you add ToolBox openfileDialog and set name.
example name is OpenFileDialog
Insert code in Button Click.
- Private Sub Button_Browse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_Browse.Click
- Dim PicturePath As String
- OpenFileDialog.InitialDirectory = "C:\"
- OpenFileDialog.Title = "Select Image File"
- OpenFileDialog.Filter = "ไฟล์ภาพ (*.jpg;*.gif;*.bmp)|*.jpg;*.gif;*.bmp"
- OpenFileDialog.ShowDialog()
- PicturePath = OpenFileDialog.FileName
- 'If Trim(PicturePath) = "" Or Len(PicturePath) = 0 Then Exit Sub
- TextBox_URL.Text = PicturePath
- 'ให้ image1 แสดงผลภาพ
- 'Image1.Picture = LoadPicture(PicturePath)
- Button_Clear.Enabled = True
- End Sub
ไม่มีความคิดเห็น:
แสดงความคิดเห็น