Minggu, 05 Januari 2014

Make Datagridview

nyampe jga d tahun baru 2014, dsni q g bingung buat nampilin nilai desimal n mrnggunakan rumus akar pake pangkat. nah tuh ..., udh akar pakai pangkat pula, jdi numpuk-numpuk kan...,
di datagridview pula..., tapi agak bingung . trus q cari wangsit kesana kemari , trus nemuin senjata ajaib.  mungkin bagi kalian ini senjata biasa tapi bagiku adalah hal yang "istimewa"... wkwkww... nih cntoh codingnya:

For i As Integer = 0 To DGV.Rows.Count - 1
            Dim hasil1 As Decimal = Round(Math.Sqrt(((DGV.Rows(i).Cells(6).Value - DGV.Rows(0).Cells(0).Value) ^ 2) + ((DGV.Rows(i).Cells(7).Value - dgvcentroid.Rows(0).Cells(1).Value) ^ 2) + ((DGV.Rows(i).Cells(8).Value - dgvcentroid.Rows(0).Cells(2).Value) ^ 2)), 3)
            Dim hasil2 As Decimal = Round(Math.Sqrt(((DGV.Rows(i).Cells(6).Value - DGV.Rows(1).Cells(0).Value) ^ 2) + ((DGV.Rows(i).Cells(7).Value - dgvcentroid.Rows(1).Cells(1).Value) ^ 2) + ((DGV.Rows(i).Cells(8).Value - dgvcentroid.Rows(1).Cells(2).Value) ^ 2)), 3)
            Dim hasil3 As Decimal = Round(Math.Sqrt(((DGV.Rows(i).Cells(6).Value - DGV.Rows(2).Cells(0).Value) ^ 2) + ((DGV.Rows(i).Cells(7).Value - dgvcentroid.Rows(2).Cells(1).Value) ^ 2) + ((DGV.Rows(i).Cells(8).Value - dgvcentroid.Rows(2).Cells(2).Value) ^ 2)), 3)

                           Dim insert As String = "INSERT INTO hasilcluster(kdpelamar,nilai,kumur,pengalaman,m1,m2,m3)VALUES" & "('" & _
                           DGV.Rows(i).Cells(0).Value & "','" & _
                           DGV.Rows(i).Cells(6).Value & "','" & _
                           DGV.Rows(i).Cells(7).Value & "','" & _
                           DGV.Rows(i).Cells(8).Value & "','" & _
                           hasil1 & "','" & hasil2 & "','" & hasil3 & "')"
                cmd = New OleDbCommand(insert, conn)
                cmd.Connection = conn
                cmd.ExecuteNonQuery()

        Next

        cmd = Nothing
        MsgBox("Saved Success!!!")
        Call panggildgv2()
n ini hasil nya..:




Tidak ada komentar:

Posting Komentar