I am trying to draw line.....Actually 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 - 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
5 1212
It would help if you could provide more information. Do you have a line number where it is occurring or can you trap it?
Well thanks for replying........Actually in my project i have 2 forms one consist of a datagrid and other form consisting of a picture box,,,,,and now when you enter data in first form you can see the drawing of your data in the other form.
also i am using vb.net for first time so if u can help me what should i use for drawing lines ...... system.drawing.graphics or system.windows.forms.paintEventargs
I am trying to draw line.....Actually 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 - 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
Total stab in the dark by someone who doesn't do VB...
In line 78 you make use of CenterFlag variable.
I see no place where you create this variable (Looks like that is done with the DIM statement as in line 10 ??)
Assuming this is a global variable created elsewhere... Is it ever initialized to a default value? CenterFlag only gets set in Verticle in line 54 if X1=X2 or to Horizontal in line 57 if Y1=Y2. What happens if neither of these conditions exist? Does CenterFlag remain unset later when it is used in line 78?
Well thanks for replying........Actually in my project i have 2 forms one consist of a datagrid and other form consisting of a picture box,,,,,and now when you enter data in first form you can see the drawing of your data in the other form.
also i am using vb.net for first time so if u can help me what should i use for drawing lines ...... system.drawing.graphics or system.windows.forms.paintEventargs
Why don't you just tell us the number reported for that exception?
Total stab in the dark by someone who doesn't do VB...
In line 78 you make use of CenterFlag variable.
I see no place where you create this variable (Looks like that is done with the DIM statement as in line 10 ??)
Assuming this is a global variable created elsewhere... Is it ever initialized to a default value? CenterFlag only gets set in Verticle in line 54 if X1=X2 or to Horizontal in line 57 if Y1=Y2. What happens if neither of these conditions exist? Does CenterFlag remain unset later when it is used in line 78?
Then it Will give us a diagonal Connection....Well Thank u .....
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Daniel |
last post by:
Hello =)
I have an object which contains a method that should execute every x ms. I
can use setInterval inside the object construct like this -
self.setInterval('ObjectName.methodName()',...
|
by: Martin |
last post by:
I'd like to be able to get the name of an object instance from within
a call to a method of that same object. Is this at all possible?
The example below works by passing in the name of the object...
|
by: Carlos Lozano |
last post by:
Hi,
What is the right way to create an OCX COM component. The component is
already registerred, but can't create an instance. I am using the reference
to the interop module created.
If I use...
|
by: Adam |
last post by:
We have a web site that uses .vb for the web pages and .cs for a class
module. We are getting the error in .NET 2.0 and VS 2005 beta 2. It does
work with .NET 1.1.
When trying to access a page...
|
by: Luke Matuszewski |
last post by:
Here are some questions that i am interested about and wanted to here
an explanation/discussion:
1. (general) Is the objectness in JavaScript was supported from the
very first version of it (in...
|
by: Andrew Poulos |
last post by:
With the following code I can't understand why this.num keeps
incrementing each time I create a new instance of Foo. For each instance
I'm expecting this.num to alert as 1 but keeps incrementing.
...
|
by: Shailen Sukul |
last post by:
Observed a weird behaviour with object references.
See code listing below:
using System;
using System.Collections.Generic;
using System.Text;
namespace PointerExceptionTest
{
/*
|
by: Philipp Reif |
last post by:
Hi all,
I've got a little hole in my head concerning references. Here's what
I'm trying to do: I'm calling a function, passing the reference of a
business object for editing. The function clones...
|
by: User1014 |
last post by:
A global variable is really just a property of the "Global Object", so
what does that make a function defined in the global context? A method
of the Global Object?
...
|
by: Ralph |
last post by:
Hi
I don't understand why it's not working:
function schedule(imTop){
this.tdImagesTop = imTop;
}
schedule.prototype.selectEl = function() {
alert(this.tdImagesTop);
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |