Hi Everybody,
I am trying to write a program that will use a Structure with <VBFixedString(4), VBFixedArray(10)> Public Test1() As String.
Back in vb6 it was in the Type statement as Test1(10) as string *4
When I hit the line ".Test1(X) = TB1" i get the following error:
Object reference not set to an instance of an object.
Below is the code, any help is greatly appriciated.
Code:Option Strict Off Option Explicit On Public Class Form1 Inherits System.Windows.Forms.Form Structure FileFormat <VBFixedString(8)> Public Username As String <VBFixedString(4), VBFixedArray(10)> Public Test1() As String <VBFixedString(4), VBFixedArray(10)> Public Test2() As String <VBFixedString(4), VBFixedArray(10)> Public Test3() As String <VBFixedString(4), VBFixedArray(10)> Public Test4() As String <VBFixedString(4), VBFixedArray(10)> Public Test5() As String End Structure Dim AllFileFormat As FileFormat Dim Username As String Dim TB1 As String Dim TB2 As String Dim TB3 As String Dim TB4 As String Dim TB5 As String Dim FN As String Dim FBuf As Short Dim FLen As Integer Dim Rec As Integer Dim Num As Short Dim X As Integer Private Sub Command1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command1.Click Rec = 1 Num = 1 Username = "TEST" TB1 = UCase(Trim(T1.Text)) TB2 = UCase(Trim(T2.Text)) TB3 = UCase(Trim(T3.Text)) TB4 = UCase(Trim(T4.Text)) TB5 = UCase(Trim(T5.Text)) FN = "D:\TestFixedArray.txt" FBuf = FreeFile FLen = Len(AllFileFormat) FileOpen(FBuf, FN, OpenMode.Random, OpenAccess.Write, OpenShare.Shared, FLen) .Username = Username For X = 1 To 10 With AllFileFormat .Test1(X) = TB1 .Test2(X) = TB2 .Test3(X) = TB3 .Test4(X) = TB4 .Test5(X) = TB5 End With Next X FilePut(FBuf, AllFileFormat, 1) FileClose(FBuf) End Sub End Class




Reply With Quote