johnny123
June 13th, 2009, 11:09 PM
Hello everybody,
I am working with .net programming. i am starter and new for .net programming. somehow i have written a code hardly. the code is working but it is taking time to calculate results. i wanted to make the calculation faster and reduce the code. its a very simple code which retrives the values from sql tables and calculates the average of 6 values. but i made it complicated. You guys please help me to reduce the code its very urgent dudes....:sick:
Here is the code....it is very big code...actually the first 20 lines repeats next 5 loops with different variables thats it..i want to make it into 1 single loop..i dont know how to do it...i will explain the code...
step1: there a 6 strings to be passed to sql database which contains stored procedures to calculate a position which passes the calculated position and probabilty to .net parameter again. i need to show the position in gui finally.
step2: Initially the 6 strings are passed and stored procedures are called to calculate position which the code is not included :)...its done already and calculation is fast....secondly i need to pass only 5 strings every time excluding one string. so i copied the same code passing only 5 by excluding 1 each and every time by FOR loop...so i am doing same process by 6 times and calculating the average of all 6 positions...
step3: what i need is... can i reduce this code by making it to single loop...to make calculation faster by using .net programming techniques...i am beginner to .net i dont know any techniques......please help me friends....if you have any questions please let me know..... please go through the code..you can understand....
Dim macs(), prob_proc() As String
Dim k, kk As Integer
Dim final_position As Integer
Dim max1(5) As Long
Dim position(5) As Long
Dim probablistic1(49) As Long
'this is the case when 1st macid is turned off...........
macs = New String() {"00112052E170", "0011218F1A60", "00112052ECC0", "00112052D840", "00112052F010", "00112052E5D0"}
prob_proc = New String() {"probs1", "probs2", "probs3", "probs4", "probs5", "probs6", "probs7", "probs8", "probs9", "probs10", "probs11", "probs12", "probs13", "probs14", "probs15", "probs16", "probs17", "probs18", "probs19", "probs20", "probs21", "probs22", "probs23", "probs24", "probs25", "probs26", "probs27", "probs28", "probs29", "probs30", "probs31", "probs32", "probs33", "probs34", "probs35", "probs36", "probs37", "probs38", "probs39", "probs40", "probs41", "probs42", "probs43", "probs44", "probs45", "probs46", "probs47", "probs48", "probs49", "probs50"}
For kk = 0 To 49
For k = 0 To 4
sqlcomm3.Connection = sqlconn
sqlcomm3.CommandType = CommandType.StoredProcedure
sqlcomm3.CommandText = prob_proc(kk)
sqlcomm3.Parameters.Clear()
q = New SqlParameter
q.ParameterName = "@macs"
q.Direction = ParameterDirection.Input
q.SqlDbType = SqlDbType.NVarChar
q.Value = macs(k)
sqlcomm3.Parameters.Add(q)
q = New SqlParameter
q.ParameterName = "@gaussian"
q.Direction = ParameterDirection.Output
q.SqlDbType = SqlDbType.Int
sqlcomm3.Parameters.Add(q)
Try
sqlcomm3.ExecuteNonQuery()
Catch ex As Exception
q.Value = 0
End Try
Try
If Convert.IsDBNull(q.Value) = True Then
q.Value = 25
End If
If q.Value < 25 Then
q.Value = 25
End If
If k = 0 Then
probablistic1(kk) = q.Value
Else
probablistic1(kk) = probablistic1(kk) * q.Value
End If
Catch ex As Exception
If k = 0 Then
probablistic1(kk) = 25
Else
probablistic1(kk) = probablistic1(kk) * 25
End If
End Try
Next
Next
max1(0) = probablistic1(0)
For kk = 0 To 49
If max1(0) < probablistic1(kk) Then
max1(0) = probablistic1(kk)
position(0) = kk
End If
Next
'__________________________________________________________________________________________________
'2)this is the case with 2nd macid is turned off.....
Dim probablistic2(49) As Long
macs = New String() {"0011218F1A60", "00112052ECC0", "00112052D840", "00112052F010", "00112052E5D0", "00112052E170"}
For kk = 0 To 49
For k = 0 To 4
sqlcomm3.Connection = sqlconn
sqlcomm3.CommandType = CommandType.StoredProcedure
sqlcomm3.CommandText = prob_proc(kk)
sqlcomm3.Parameters.Clear()
q = New SqlParameter
q.ParameterName = "@macs"
q.Direction = ParameterDirection.Input
q.SqlDbType = SqlDbType.NVarChar
q.Value = macs(k)
sqlcomm3.Parameters.Add(q)
q = New SqlParameter
q.ParameterName = "@gaussian"
q.Direction = ParameterDirection.Output
q.SqlDbType = SqlDbType.Int
sqlcomm3.Parameters.Add(q)
Try
sqlcomm3.ExecuteNonQuery()
Catch ex As Exception
q.Value = 0
End Try
Try
If Convert.IsDBNull(q.Value) = True Then
q.Value = 25
End If
If q.Value < 25 Then
q.Value = 25
End If
If k = 0 Then
probablistic2(kk) = q.Value
Else
probablistic2(kk) = probablistic2(kk) * q.Value
End If
Catch ex As Exception
If k = 0 Then
probablistic2(kk) = 25
Else
probablistic2(kk) = probablistic2(kk) * 25
End If
End Try
Next
Next
max1(1) = probablistic2(0)
For kk = 0 To 49
If max1(1) < probablistic2(kk) Then
max1(1) = probablistic2(kk)
position(1) = kk
End If
Next
'--------------------------------------------------------------------------------------------------
'this is the case for 3rd macid is off...
Dim probablistic3(49) As Long
macs = New String() {"00112052ECC0", "00112052D840", "00112052F010", "00112052E5D0", "00112052E170", "0011218F1A60"}
For kk = 0 To 49
For k = 0 To 4
sqlcomm3.Connection = sqlconn
sqlcomm3.CommandType = CommandType.StoredProcedure
sqlcomm3.CommandText = prob_proc(kk)
sqlcomm3.Parameters.Clear()
q = New SqlParameter
q.ParameterName = "@macs"
q.Direction = ParameterDirection.Input
q.SqlDbType = SqlDbType.NVarChar
q.Value = macs(k)
sqlcomm3.Parameters.Add(q)
q = New SqlParameter
q.ParameterName = "@gaussian"
q.Direction = ParameterDirection.Output
q.SqlDbType = SqlDbType.Int
sqlcomm3.Parameters.Add(q)
Try
sqlcomm3.ExecuteNonQuery()
Catch ex As Exception
q.Value = 0
End Try
Try
If Convert.IsDBNull(q.Value) = True Then
q.Value = 25
End If
If q.Value < 25 Then
q.Value = 25
End If
If k = 0 Then
probablistic3(kk) = q.Value
Else
probablistic3(kk) = probablistic3(kk) * q.Value
End If
Catch ex As Exception
If k = 0 Then
probablistic3(kk) = 25
Else
probablistic3(kk) = probablistic3(kk) * 25
End If
End Try
Next
Next
max1(2) = probablistic3(0)
For kk = 0 To 49
If max1(2) < probablistic3(kk) Then
max1(2) = probablistic3(kk)
position(2) = kk
End If
Next
'--------------------------------------------------------------------------------------------------------------
'this is the case when 4th macid is off.....
macs = New String() {"00112052D840", "00112052F010", "00112052E5D0", "00112052E170", "0011218F1A60", "00112052ECC0"}
Dim probablistic4(49) As Long
For kk = 0 To 49
For k = 0 To 4
sqlcomm3.Connection = sqlconn
sqlcomm3.CommandType = CommandType.StoredProcedure
sqlcomm3.CommandText = prob_proc(kk)
sqlcomm3.Parameters.Clear()
q = New SqlParameter
q.ParameterName = "@macs"
q.Direction = ParameterDirection.Input
q.SqlDbType = SqlDbType.NVarChar
q.Value = macs(k)
sqlcomm3.Parameters.Add(q)
q = New SqlParameter
q.ParameterName = "@gaussian"
q.Direction = ParameterDirection.Output
q.SqlDbType = SqlDbType.Int
sqlcomm3.Parameters.Add(q)
Try
sqlcomm3.ExecuteNonQuery()
Catch ex As Exception
q.Value = 0
End Try
Try
If Convert.IsDBNull(q.Value) = True Then
q.Value = 25
End If
If q.Value < 25 Then
q.Value = 25
End If
If k = 0 Then
probablistic4(kk) = q.Value
Else
probablistic4(kk) = probablistic4(kk) * q.Value
End If
Catch ex As Exception
If k = 0 Then
probablistic4(kk) = 25
Else
probablistic4(kk) = probablistic4(kk) * 25
End If
End Try
Next
Next
max1(3) = probablistic4(0)
For kk = 0 To 49
If max1(3) < probablistic4(kk) Then
max1(3) = probablistic4(kk)
position(3) = kk
End If
Next
'--------------------------------------------------------------------------------------------------
'this is the case when 5th macid is turned off......
macs = New String() {"00112052F010", "00112052E5D0", "00112052E170", "0011218F1A60", "00112052ECC0", "00112052D840"}
Dim probablistic5(49) As Long
For kk = 0 To 49
For k = 0 To 4
sqlcomm3.Connection = sqlconn
sqlcomm3.CommandType = CommandType.StoredProcedure
sqlcomm3.CommandText = prob_proc(kk)
sqlcomm3.Parameters.Clear()
q = New SqlParameter
q.ParameterName = "@macs"
q.Direction = ParameterDirection.Input
q.SqlDbType = SqlDbType.NVarChar
q.Value = macs(k)
sqlcomm3.Parameters.Add(q)
q = New SqlParameter
q.ParameterName = "@gaussian"
q.Direction = ParameterDirection.Output
q.SqlDbType = SqlDbType.Int
sqlcomm3.Parameters.Add(q)
Try
sqlcomm3.ExecuteNonQuery()
Catch ex As Exception
q.Value = 0
End Try
Try
If Convert.IsDBNull(q.Value) = True Then
q.Value = 25
End If
If q.Value < 25 Then
q.Value = 25
End If
If k = 0 Then
probablistic5(kk) = q.Value
Else
probablistic5(kk) = probablistic5(kk) * q.Value
End If
Catch ex As Exception
If k = 0 Then
probablistic5(kk) = 25
Else
probablistic5(kk) = probablistic5(kk) * 25
End If
End Try
Next
Next
max1(4) = probablistic5(0)
For kk = 0 To 49
If max1(4) < probablistic5(kk) Then
max1(4) = probablistic5(kk)
position(4) = kk
End If
Next
'-------------------------------------------------------------------------------------------------
'this is the case when 6th macid is turned off....
macs = New String() {"00112052E5D0", "00112052E170", "0011218F1A60", "00112052ECC0", "00112052D840", "00112052F010"}
Dim probablistic6(49) As Long
For kk = 0 To 49
For k = 0 To 4
sqlcomm3.Connection = sqlconn
sqlcomm3.CommandType = CommandType.StoredProcedure
sqlcomm3.CommandText = prob_proc(kk)
sqlcomm3.Parameters.Clear()
q = New SqlParameter
q.ParameterName = "@macs"
q.Direction = ParameterDirection.Input
q.SqlDbType = SqlDbType.NVarChar
q.Value = macs(k)
sqlcomm3.Parameters.Add(q)
q = New SqlParameter
q.ParameterName = "@gaussian"
q.Direction = ParameterDirection.Output
q.SqlDbType = SqlDbType.Int
sqlcomm3.Parameters.Add(q)
Try
sqlcomm3.ExecuteNonQuery()
Catch ex As Exception
q.Value = 0
End Try
Try
If Convert.IsDBNull(q.Value) = True Then
q.Value = 25
End If
If q.Value < 25 Then
q.Value = 25
End If
If k = 0 Then
probablistic6(kk) = q.Value
Else
probablistic6(kk) = probablistic6(kk) * q.Value
End If
Catch ex As Exception
If k = 0 Then
probablistic6(kk) = 25
Else
probablistic6(kk) = probablistic6(kk) * 25
End If
End Try
Next
Next
max1(5) = probablistic6(0)
For kk = 0 To 49
If max1(5) < probablistic6(kk) Then
max1(5) = probablistic6(kk)
position(5) = kk
End If
Next
final_position = (position(0) + position(1) + position(2) + position(3) + position(4) + position(5)) / 6
Me.Controls.Remove(pbox)
SuspendLayout()
pbox.Image = System.Drawing.Image.FromFile(("C:\XandY\Image\dot2.jpg"))
pbox.Top = pointx(final_position + 1).Y
pbox.Left = pointx(final_position + 1).X
pbox.Width = 10
pbox.Height = 10
Me.Controls.Add(pbox)
pbox.BringToFront()
ResumeLayout()
End If
End If
End Sub
I am working with .net programming. i am starter and new for .net programming. somehow i have written a code hardly. the code is working but it is taking time to calculate results. i wanted to make the calculation faster and reduce the code. its a very simple code which retrives the values from sql tables and calculates the average of 6 values. but i made it complicated. You guys please help me to reduce the code its very urgent dudes....:sick:
Here is the code....it is very big code...actually the first 20 lines repeats next 5 loops with different variables thats it..i want to make it into 1 single loop..i dont know how to do it...i will explain the code...
step1: there a 6 strings to be passed to sql database which contains stored procedures to calculate a position which passes the calculated position and probabilty to .net parameter again. i need to show the position in gui finally.
step2: Initially the 6 strings are passed and stored procedures are called to calculate position which the code is not included :)...its done already and calculation is fast....secondly i need to pass only 5 strings every time excluding one string. so i copied the same code passing only 5 by excluding 1 each and every time by FOR loop...so i am doing same process by 6 times and calculating the average of all 6 positions...
step3: what i need is... can i reduce this code by making it to single loop...to make calculation faster by using .net programming techniques...i am beginner to .net i dont know any techniques......please help me friends....if you have any questions please let me know..... please go through the code..you can understand....
Dim macs(), prob_proc() As String
Dim k, kk As Integer
Dim final_position As Integer
Dim max1(5) As Long
Dim position(5) As Long
Dim probablistic1(49) As Long
'this is the case when 1st macid is turned off...........
macs = New String() {"00112052E170", "0011218F1A60", "00112052ECC0", "00112052D840", "00112052F010", "00112052E5D0"}
prob_proc = New String() {"probs1", "probs2", "probs3", "probs4", "probs5", "probs6", "probs7", "probs8", "probs9", "probs10", "probs11", "probs12", "probs13", "probs14", "probs15", "probs16", "probs17", "probs18", "probs19", "probs20", "probs21", "probs22", "probs23", "probs24", "probs25", "probs26", "probs27", "probs28", "probs29", "probs30", "probs31", "probs32", "probs33", "probs34", "probs35", "probs36", "probs37", "probs38", "probs39", "probs40", "probs41", "probs42", "probs43", "probs44", "probs45", "probs46", "probs47", "probs48", "probs49", "probs50"}
For kk = 0 To 49
For k = 0 To 4
sqlcomm3.Connection = sqlconn
sqlcomm3.CommandType = CommandType.StoredProcedure
sqlcomm3.CommandText = prob_proc(kk)
sqlcomm3.Parameters.Clear()
q = New SqlParameter
q.ParameterName = "@macs"
q.Direction = ParameterDirection.Input
q.SqlDbType = SqlDbType.NVarChar
q.Value = macs(k)
sqlcomm3.Parameters.Add(q)
q = New SqlParameter
q.ParameterName = "@gaussian"
q.Direction = ParameterDirection.Output
q.SqlDbType = SqlDbType.Int
sqlcomm3.Parameters.Add(q)
Try
sqlcomm3.ExecuteNonQuery()
Catch ex As Exception
q.Value = 0
End Try
Try
If Convert.IsDBNull(q.Value) = True Then
q.Value = 25
End If
If q.Value < 25 Then
q.Value = 25
End If
If k = 0 Then
probablistic1(kk) = q.Value
Else
probablistic1(kk) = probablistic1(kk) * q.Value
End If
Catch ex As Exception
If k = 0 Then
probablistic1(kk) = 25
Else
probablistic1(kk) = probablistic1(kk) * 25
End If
End Try
Next
Next
max1(0) = probablistic1(0)
For kk = 0 To 49
If max1(0) < probablistic1(kk) Then
max1(0) = probablistic1(kk)
position(0) = kk
End If
Next
'__________________________________________________________________________________________________
'2)this is the case with 2nd macid is turned off.....
Dim probablistic2(49) As Long
macs = New String() {"0011218F1A60", "00112052ECC0", "00112052D840", "00112052F010", "00112052E5D0", "00112052E170"}
For kk = 0 To 49
For k = 0 To 4
sqlcomm3.Connection = sqlconn
sqlcomm3.CommandType = CommandType.StoredProcedure
sqlcomm3.CommandText = prob_proc(kk)
sqlcomm3.Parameters.Clear()
q = New SqlParameter
q.ParameterName = "@macs"
q.Direction = ParameterDirection.Input
q.SqlDbType = SqlDbType.NVarChar
q.Value = macs(k)
sqlcomm3.Parameters.Add(q)
q = New SqlParameter
q.ParameterName = "@gaussian"
q.Direction = ParameterDirection.Output
q.SqlDbType = SqlDbType.Int
sqlcomm3.Parameters.Add(q)
Try
sqlcomm3.ExecuteNonQuery()
Catch ex As Exception
q.Value = 0
End Try
Try
If Convert.IsDBNull(q.Value) = True Then
q.Value = 25
End If
If q.Value < 25 Then
q.Value = 25
End If
If k = 0 Then
probablistic2(kk) = q.Value
Else
probablistic2(kk) = probablistic2(kk) * q.Value
End If
Catch ex As Exception
If k = 0 Then
probablistic2(kk) = 25
Else
probablistic2(kk) = probablistic2(kk) * 25
End If
End Try
Next
Next
max1(1) = probablistic2(0)
For kk = 0 To 49
If max1(1) < probablistic2(kk) Then
max1(1) = probablistic2(kk)
position(1) = kk
End If
Next
'--------------------------------------------------------------------------------------------------
'this is the case for 3rd macid is off...
Dim probablistic3(49) As Long
macs = New String() {"00112052ECC0", "00112052D840", "00112052F010", "00112052E5D0", "00112052E170", "0011218F1A60"}
For kk = 0 To 49
For k = 0 To 4
sqlcomm3.Connection = sqlconn
sqlcomm3.CommandType = CommandType.StoredProcedure
sqlcomm3.CommandText = prob_proc(kk)
sqlcomm3.Parameters.Clear()
q = New SqlParameter
q.ParameterName = "@macs"
q.Direction = ParameterDirection.Input
q.SqlDbType = SqlDbType.NVarChar
q.Value = macs(k)
sqlcomm3.Parameters.Add(q)
q = New SqlParameter
q.ParameterName = "@gaussian"
q.Direction = ParameterDirection.Output
q.SqlDbType = SqlDbType.Int
sqlcomm3.Parameters.Add(q)
Try
sqlcomm3.ExecuteNonQuery()
Catch ex As Exception
q.Value = 0
End Try
Try
If Convert.IsDBNull(q.Value) = True Then
q.Value = 25
End If
If q.Value < 25 Then
q.Value = 25
End If
If k = 0 Then
probablistic3(kk) = q.Value
Else
probablistic3(kk) = probablistic3(kk) * q.Value
End If
Catch ex As Exception
If k = 0 Then
probablistic3(kk) = 25
Else
probablistic3(kk) = probablistic3(kk) * 25
End If
End Try
Next
Next
max1(2) = probablistic3(0)
For kk = 0 To 49
If max1(2) < probablistic3(kk) Then
max1(2) = probablistic3(kk)
position(2) = kk
End If
Next
'--------------------------------------------------------------------------------------------------------------
'this is the case when 4th macid is off.....
macs = New String() {"00112052D840", "00112052F010", "00112052E5D0", "00112052E170", "0011218F1A60", "00112052ECC0"}
Dim probablistic4(49) As Long
For kk = 0 To 49
For k = 0 To 4
sqlcomm3.Connection = sqlconn
sqlcomm3.CommandType = CommandType.StoredProcedure
sqlcomm3.CommandText = prob_proc(kk)
sqlcomm3.Parameters.Clear()
q = New SqlParameter
q.ParameterName = "@macs"
q.Direction = ParameterDirection.Input
q.SqlDbType = SqlDbType.NVarChar
q.Value = macs(k)
sqlcomm3.Parameters.Add(q)
q = New SqlParameter
q.ParameterName = "@gaussian"
q.Direction = ParameterDirection.Output
q.SqlDbType = SqlDbType.Int
sqlcomm3.Parameters.Add(q)
Try
sqlcomm3.ExecuteNonQuery()
Catch ex As Exception
q.Value = 0
End Try
Try
If Convert.IsDBNull(q.Value) = True Then
q.Value = 25
End If
If q.Value < 25 Then
q.Value = 25
End If
If k = 0 Then
probablistic4(kk) = q.Value
Else
probablistic4(kk) = probablistic4(kk) * q.Value
End If
Catch ex As Exception
If k = 0 Then
probablistic4(kk) = 25
Else
probablistic4(kk) = probablistic4(kk) * 25
End If
End Try
Next
Next
max1(3) = probablistic4(0)
For kk = 0 To 49
If max1(3) < probablistic4(kk) Then
max1(3) = probablistic4(kk)
position(3) = kk
End If
Next
'--------------------------------------------------------------------------------------------------
'this is the case when 5th macid is turned off......
macs = New String() {"00112052F010", "00112052E5D0", "00112052E170", "0011218F1A60", "00112052ECC0", "00112052D840"}
Dim probablistic5(49) As Long
For kk = 0 To 49
For k = 0 To 4
sqlcomm3.Connection = sqlconn
sqlcomm3.CommandType = CommandType.StoredProcedure
sqlcomm3.CommandText = prob_proc(kk)
sqlcomm3.Parameters.Clear()
q = New SqlParameter
q.ParameterName = "@macs"
q.Direction = ParameterDirection.Input
q.SqlDbType = SqlDbType.NVarChar
q.Value = macs(k)
sqlcomm3.Parameters.Add(q)
q = New SqlParameter
q.ParameterName = "@gaussian"
q.Direction = ParameterDirection.Output
q.SqlDbType = SqlDbType.Int
sqlcomm3.Parameters.Add(q)
Try
sqlcomm3.ExecuteNonQuery()
Catch ex As Exception
q.Value = 0
End Try
Try
If Convert.IsDBNull(q.Value) = True Then
q.Value = 25
End If
If q.Value < 25 Then
q.Value = 25
End If
If k = 0 Then
probablistic5(kk) = q.Value
Else
probablistic5(kk) = probablistic5(kk) * q.Value
End If
Catch ex As Exception
If k = 0 Then
probablistic5(kk) = 25
Else
probablistic5(kk) = probablistic5(kk) * 25
End If
End Try
Next
Next
max1(4) = probablistic5(0)
For kk = 0 To 49
If max1(4) < probablistic5(kk) Then
max1(4) = probablistic5(kk)
position(4) = kk
End If
Next
'-------------------------------------------------------------------------------------------------
'this is the case when 6th macid is turned off....
macs = New String() {"00112052E5D0", "00112052E170", "0011218F1A60", "00112052ECC0", "00112052D840", "00112052F010"}
Dim probablistic6(49) As Long
For kk = 0 To 49
For k = 0 To 4
sqlcomm3.Connection = sqlconn
sqlcomm3.CommandType = CommandType.StoredProcedure
sqlcomm3.CommandText = prob_proc(kk)
sqlcomm3.Parameters.Clear()
q = New SqlParameter
q.ParameterName = "@macs"
q.Direction = ParameterDirection.Input
q.SqlDbType = SqlDbType.NVarChar
q.Value = macs(k)
sqlcomm3.Parameters.Add(q)
q = New SqlParameter
q.ParameterName = "@gaussian"
q.Direction = ParameterDirection.Output
q.SqlDbType = SqlDbType.Int
sqlcomm3.Parameters.Add(q)
Try
sqlcomm3.ExecuteNonQuery()
Catch ex As Exception
q.Value = 0
End Try
Try
If Convert.IsDBNull(q.Value) = True Then
q.Value = 25
End If
If q.Value < 25 Then
q.Value = 25
End If
If k = 0 Then
probablistic6(kk) = q.Value
Else
probablistic6(kk) = probablistic6(kk) * q.Value
End If
Catch ex As Exception
If k = 0 Then
probablistic6(kk) = 25
Else
probablistic6(kk) = probablistic6(kk) * 25
End If
End Try
Next
Next
max1(5) = probablistic6(0)
For kk = 0 To 49
If max1(5) < probablistic6(kk) Then
max1(5) = probablistic6(kk)
position(5) = kk
End If
Next
final_position = (position(0) + position(1) + position(2) + position(3) + position(4) + position(5)) / 6
Me.Controls.Remove(pbox)
SuspendLayout()
pbox.Image = System.Drawing.Image.FromFile(("C:\XandY\Image\dot2.jpg"))
pbox.Top = pointx(final_position + 1).Y
pbox.Left = pointx(final_position + 1).X
pbox.Width = 10
pbox.Height = 10
Me.Controls.Add(pbox)
pbox.BringToFront()
ResumeLayout()
End If
End If
End Sub