Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 149,563 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,652 people online right now. Registration is fast and FREE... Join Now!




Saving to a sequential access file

 
Reply to this topicStart new topic

Saving to a sequential access file

tseilheimer
1 Dec, 2007 - 10:28 AM
Post #1

New D.I.C Head
*

Joined: 10 Nov, 2007
Posts: 9


My Contributions
My project is to create a program where the user can enter check information and the program saves it in a sequential access file. I'm getting an error when I run the program. The error is "Object reference not set to an instance of an object." and I'm getting it on the line that I have *** in front of below, towards the bottom of the code. Can anyone offer suggestions to how I might fix this error? Thanks for your help.



CODE

Option Explicit On
Option Strict On
Public Class Form1

    Public Class payment
        Public checknumber As String
        Public checkdate As Date
        Public payee As String
        Public checkamount As Decimal
    End Class

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.Close()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim path As String = "C:\documents and settings\tammy and rich\my documents\visual studio 2005\projects\franklin calendars"
        Dim ourcheck As New payment
        Dim newlineindex As Integer
        Dim recordindex As Integer
        If checknumbertextbox.Text <> String.Empty AndAlso checkdatetextbox.Text <> String.Empty AndAlso payeetextbox.Text <> String.Empty AndAlso checkamounttextbox.Text <> String.Empty Then
            ourcheck.checknumber = checknumbertextbox.Text
            newlineindex = Text.IndexOf(ControlChars.NewLine, recordIndex)
*****   My.Computer.FileSystem.WriteAllText(path & "checkfile.txt", ourcheck.checknumber.PadRight(20) & ourcheck.checkdate.ToString.PadLeft(10) & ourcheck.payee.ToString.PadLeft(10) & ourcheck.checkamount.ToString("N2").PadLeft(10) & ControlChars.NewLine, True)
            checknumbertextbox.Text = String.Empty
            checkdatetextbox.Text = String.Empty
            payeetextbox.Text = String.Empty
            checkamounttextbox.Text = String.Empty
        End If
        checknumbertextbox.Focus()
    End Sub

End Class

User is offlineProfile CardPM
+Quote Post

Wanting2Learn
RE: Saving To A Sequential Access File
30 Jan, 2008 - 03:45 PM
Post #2

New D.I.C Head
*

Joined: 29 Jan, 2008
Posts: 4

Did you ever develop a solution?
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 10:13PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month