How in VB .NET to correct errors?


D

Dr. Zharkov

Hello. A problem in the following.
In VB .NET 2003 I create the project and in file Form1.vb is written down
the following code:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Create the data:
CreateData() 'Error
End Sub

'Create the data:
Private Sub CreateData()
'Axes X, Y, Z:
MakeSegment(0, 0, 0, 0.5, 0, 0) ' X axis. 'Error
MakeSegment(0, 0, 0, 0, 0.5, 0) ' Y axis.
MakeSegment(0, 0, 0, 0, 0, 0.5) ' Z axis.
End Sub

Public Structure Segment
'Connect the points:
<VBFixedArray(4)> Dim fr_pt() As Single
<VBFixedArray(4)> Dim to_pt() As Single
'Connect the transformed points:
<VBFixedArray(4)> Dim fr_tr() As Single
<VBFixedArray(4)> Dim to_tr() As Single
Public Sub Initialize()
ReDim fr_pt(4)
ReDim to_pt(4)
ReDim fr_tr(4)
ReDim to_tr(4)
End Sub
End Structure

Public Structure Transformation
<VBFixedArray(4, 4)> Dim M(,) As Single
Public Sub Initialize()
ReDim M(4, 4)
End Sub
End Structure

Public NumSegments As Short
Public Segments() As Segment

'Create a segment:
Public Sub MakeSegment(ByVal x1 As Single, ByVal y1 As Single, ByVal z1
As Single, _
ByVal x2 As Single, ByVal y2 As Single, ByVal z2
As Single)
NumSegments = NumSegments + 1
ReDim Preserve Segments(NumSegments)
Segments(NumSegments).fr_pt(1) = x1 'Error
Segments(NumSegments).fr_pt(2) = y1
Segments(NumSegments).fr_pt(3) = z1
Segments(NumSegments).fr_pt(4) = 1
Segments(NumSegments).to_pt(1) = x2
Segments(NumSegments).to_pt(2) = y2
Segments(NumSegments).to_pt(3) = z2
Segments(NumSegments).to_pt(4) = 1
End Sub

Building the project (Build, Build Solution) is carried out without errors.
However at running there are errors in the specified lines and the message:
Object reference not set to an instance of an object.

Inform, please, how to correct errors?

Beforehand many thanks for answer. Best regards, Dr. V.A. Zharkov. Moscow,
Russia.
 
Ad

Advertisements

A

Armin Zingler

Dr. Zharkov said:
NumSegments = NumSegments + 1
ReDim Preserve Segments(NumSegments)
Segments(NumSegments).Initialize

Segments(NumSegments).fr_pt(1) = x1 'Error
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

How in VB .NET to correct errors? 13
Error handling in vb. net 3
VB to .Net 6
VB SCript in .NET? 9
C# to VB .NET 1
VB and .NET Framework 5
Datagrid VB net 4
How to build 3D-graphics in VB .NET? 0

Top