I am trying to draw line.....Actual ly these codes were previously in vb 6...i tried to change them in vb.net....but every time i try to run the application i got this error ."Object reference not set to an instance of an object"...plz help me regerding this error....here are my code
Code:
Sub BeamDraw(ByRef DrawControl As PaintEventArgs, ByRef ds As DAO.Recordset)
Dim Y5 As Double
Dim X5 As Double
Dim Y2 As Double
Dim X2 As Double
Dim Y3 As Double
Dim X3 As Double
Dim Y1 As Double
Dim X1 As Double
Dim szcolumn As String
Dim X As Single
Dim Y As Single
Dim Dc As DAO.Recordset
Dim DCC As DAO.Recordset
DCC = CurDb.OpenRecordset("Columns", DAO.RecordsetTypeEnum.dbOpenDynaset)
Dc = CurDb.OpenRecordset("Columns", DAO.RecordsetTypeEnum.dbOpenDynaset)
While Not ds.EOF
szcolumn = "Cname='" + ds.Fields(0).Value + "'"
DCC.FindFirst(szcolumn)
X = DCC.Fields(4).Value
Y = DCC.Fields(5).Value
X1 = DCC.Fields(4).Value
Y1 = DCC.Fields(5).Value
FlushDistances(DCC, X, Y)
X3 = X
Y3 = Y
If StrComp(Left(DCC.Fields(0).Value, 1), "C") = 0 Then
Select Case DCC.Fields(1).Value
Case "H"
DrawControl.Graphics.DrawLine(Pens.OrangeRed, CInt(X - DCC.Fields(2).Value / 2), CInt(Y - DCC.Fields(3).Value / 2) - CInt(X + DCC.Fields(2).Value / 2), CInt(Y + DCC.Fields(3).Value / 2), B)
End Select
Else
Select Case DCC.Fields(1).Value
Case "H"
DrawControl.Graphics.DrawLine(Pens.OrangeRed, CInt(X - DCC.Fields(2).Value / 2), CInt(Y - DCC.Fields(3).Value / 2) - CInt(X + DCC.Fields(2).Value / 2), CInt(Y + DCC.Fields(3).Value / 2), B)
End Select
End If
If Enlarge Or BeamSelect Then
Column_Dis(DCC.Fields(4).Value + DCC.Fields(2).Value / 2, DCC.Fields(5).Value - DCC.Fields(3).Value / 2, DCC.Fields(0).Value, DrawControl)
End If
szcolumn = "Cname='" + ds.Fields(1).Value + "'"
Dc.FindFirst(szcolumn)
X = (Dc.Fields(4).Value)
Y = (Dc.Fields(5).Value)
X2 = Dc.Fields(4).Value
Y2 = Dc.Fields(5).Value
FlushDistances(Dc, X, Y)
X5 = X
Y5 = Y
If X1 = X2 Then
CenterFlag = "BeamVertical"
Else
If Y1 = Y2 Then
CenterFlag = "BeamHorizontal"
End If
End If
If StrComp(Left(Dc.Fields(0).Value, 1), "C") = 0 Then
Select Case Dc.Fields(1).Value
Case "H"
DrawControl.Graphics.DrawLine(Pens.OrangeRed, CInt(X - Dc.Fields(2).Value / 2), CInt(Y - Dc.Fields(3).Value / 2), CInt(X + Dc.Fields(2).Value / 2), CInt(Y + Dc.Fields(3).Value / 2))
End Select
Else
Select Case Dc.Fields(1).Value
Case "H"
DrawControl.Graphics.DrawLine(Pens.OrangeRed, CInt(X - Dc.Fields(2).Value / 2), CInt(Y - Dc.Fields(3).Value / 2) - CInt(X + Dc.Fields(2).Value / 2), CInt(Y + Dc.Fields(3).Value / 2), B)
End Select
End If
If Enlarge Or BeamSelect Then
Column_Dis(Dc.Fields(4).Value + Dc.Fields(2).Value / 2, Dc.Fields(5).Value - Dc.Fields(3).Value / 2, Dc.Fields(0).Value, DrawControl)
End If
ShowBeam(ds, DCC, DCC, DrawControl, X3, Y3, X5, Y5, CenterFlag)
ds.MoveNext()
End While
End Sub
Comment