OpenFileDialog1.Filter = "Excel Files (*.xlsx,*.xls)|*.xlsx;*.xls"
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim address As String = OpenFileDialog1.FileName
Dim excel As New Excel.Application
Dim wbook As Excel.Workbook = excel.Workbooks.Open(address)
Dim wsheet As Excel.Worksheet = DirectCast(wbook.Worksheets(1), Excel.Worksheet)
excel.Visible = False
Dim i, j As Integer
i = 0
Do While IsNumeric(wsheet.Cells(i + 3, 2).value) = True 'นับแถว RoW
i += 1
RowE = i
Loop
j = 0
Do While IsNumeric(wsheet.Cells(3, j + 2).value) = True 'นับ Column
j += 1
ColumnE = j
Loop
'MessageBox.Show(RowE & "," & ColumnE)
ReDim Dta(RowE, ColumnE)
ReDim Dta2(RowE, ColumnE)
For x = 1 To RowE
For y = 1 To ColumnE
Dta(x, y) = wsheet.Cells(x + 2, y + 1).value
Dta2(x, y) = wsheet.Cells(x + 2, y + 1).value
'MessageBox.Show(Dta(x, y))
'ComboBox1.Items.Add(Dta(x, y))
Next
Next
ปกติถ้าคุณ Close หรือ Quit ถูกต้องมันก็จะไม่มี Process ค้างน่ะครับ ลองเข้าไปดูวิธ๊ในบทความที่เกี่ยวกับ Excel ครับ
Date :
2014-03-17 06:46:08
By :
mr.win
No. 2
Guest
kill process by name
Code (VB.NET)
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Call killprocess function and send the name of the program you'd like to kill
killprocess("calc") 'ชื่อ process ที่จะ kill
End Sub
Public Function killprocess(ByVal processname As String)
'Get list of all running processes
Dim proc() As Process = Process.GetProcesses
'Loop through all processes
For i As Integer = 0 To proc.GetUpperBound(0)
If proc(i).ProcessName = processname Then
'kill process if name is calc
proc(i).Kill()
MessageBox.Show("ปิด process calculator เรียบร้อยแล้ว!", "www.thaicreate.com", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
Next
End Function
End Class