Logo 
Search:

Technical Conversation of Priya

 
Enter your message (HTML allowed after you earn 150 points)
Priya Mohana
  Priya Mohana from India    Jan 06
This is the code i have tried............

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
MsgBox("Creating Proximity Matrix....")
Dim xlApp As Excel.Application
Dim xlWorkBook As Excel.Workbook
Dim x2WorkSheet As Excel.Worksheet
Dim x3WorkSheet As Excel.Worksheet
Try
xlApp = New Excel.ApplicationClass
xlWorkBook = xlApp.Workbooks.Open("C:\Users\priya\Desktop\Project\Book1.xlsx")
x2WorkSheet = xlWorkBook.Worksheets("Sheet2")
x3WorkSheet = xlWorkBook.Worksheets("Sheet3")
Dim i, j, rCnt, cCnt, temp, rows, cols, dataCnt As Integer
rows = 5
cols = 5
For rCnt = 1 To rows
dataCnt = 1
For cCnt = 1 To cols
'MsgBox(x2WorkSheet.Cells(rCnt, cCnt).Value.ToString)
data(dataCnt) = x2WorkSheet.Cells(rCnt, cCnt).Value
tmpdata(dataCnt) = x2WorkSheet.Cells(rCnt, cCnt).Value
backup(rCnt, cCnt) = data(dataCnt)
dataCnt = dataCnt + 1
Next cCnt
dataCnt = dataCnt - 1
For i = 1 To dataCnt - 1
For j = i + 1 To dataCnt
If data(i) < data(j) Then
temp = data(i)
data(i) = data(j)
data(j) = temp
End If
Next
Next
rescnt = 1
For i = 1 To dataCnt - 1
For j = 1 To dataCnt
If ((data(i) = tmpdata(j)) And (data(i) <> 0) And (tmpdata(j) <> 0)) Then
res(rescnt) = j
End If
rescnt = rescnt + 1
Next
MsgBox(res(1))
MsgBox(res(2))
Next
Next rCnt

xlWorkBook.Close()
Finally
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp)
End Try
MsgBox("Proximity Matrix Created...")

End
End Sub


End Class