473,757 Members | 2,066 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Saving data to a sequential access file - Visual Basic 2005 Express

24 New Member
Hi, I'm trying to create a program where the user can enter check information and the information is saved to 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 the ***** in front of below. Can anyone help me figure out how to fix this error? Thanks for your help. Here's my code:


Expand|Select|Wrap|Line Numbers
  1. Option Explicit On
  2. Option Strict On
  3. Public Class Form1
  4.  
  5.     Public Class payment
  6.         Public checknumber As String
  7.         Public checkdate As Date
  8.         Public payee As String
  9.         Public checkamount As Decimal
  10.     End Class
  11.  
  12.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  13.         Me.Close()
  14.     End Sub
  15.  
  16.  
  17.  
  18.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  19.         Dim path As String = "C:\documents and settings\tammy and rich\my documents\visual studio 2005\projects\franklin calendars"
  20.         Dim ourcheck As New payment
  21.         Dim newlineindex As Integer
  22.         Dim recordindex As Integer
  23.         If checknumbertextbox.Text <> String.Empty AndAlso checkdatetextbox.Text <> String.Empty AndAlso payeetextbox.Text <> String.Empty AndAlso checkamounttextbox.Text <> String.Empty Then
  24.             ourcheck.checknumber = checknumbertextbox.Text
  25.             newlineindex = Text.IndexOf(ControlChars.NewLine, recordIndex)
  26.     *******   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)
  27.             checknumbertextbox.Text = String.Empty
  28.             checkdatetextbox.Text = String.Empty
  29.             payeetextbox.Text = String.Empty
  30.             checkamounttextbox.Text = String.Empty
  31.         End If
  32.         checknumbertextbox.Focus()
  33.  
Dec 2 '07 #1
2 1543
kenobewan
4,871 Recognized Expert Specialist
One reason is that the file being in franklin calendars there is no '\' between, ie the current path is '\franklin calendarscheckf ile.txt'. HTH.
Dec 2 '07 #2
Michelle Monty
24 New Member
Thanks. I fixed that line but I'm getting the same error.

One reason is that the file being in franklin calendars there is no '\' between, ie the current path is '\franklin calendarscheckf ile.txt'. HTH.
Dec 2 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

33
5952
by: Uwe Range | last post by:
Hi to all! A customer of mine told me some days ago that her IT-people told her ACCESS would not be such a good idea for continuing with our project, because Access will not be continued in the future. I haven't heard of this. Does anybody know more about it? The IT-People usually prefer Oracle. If they really want to go in this direction, could our Access-application (if continued) be used as a front end with an Oracle back end? Does...
0
1230
by: cronman | last post by:
I am creating a small Windows application using Visual C# 2005 Express Edition (August CTP) for a small non-profit agency. My current issue is with updating related information in an Access database. The individual records are being saved to the database with a few issues... Notes: 1) I was going to post the source code from a test program I developed for testing these issues, but it made for a messy post. Here is a link to a zip...
9
4971
by: Neil | last post by:
We have an Access 2000 MDB with a SQL 7 back end. We are upgrading SQL Server to SQL 2005, and are considering upgrading to Access 2003. Someone mentioned that they had heard about some incompatibilities between Access 2003 and SQL Server 2005. Anyone hear of anything? And, if so, would staying with Access 2000 be better? Thanks! Neil
3
2359
by: VB.NET | last post by:
I'm using a mysql database and connecting my vb.net program to the DB over a network connection. i would like to bring this data over to a vb.net random access file. does anyone know how to convert my DB into a binary file? and how to convert my code to use a file instead of the db?
11
3438
by: mesut demir | last post by:
Hi All, When I create fields (in files) I need assign a data type like char, varchar, money etc. I have some questions about the data types when you create fields in a file. What is the difference between data type 'CHAR' and 'TEXT'? When do you use 'VAR' in your datatype word? e.g. VARCHAR ?
6
8124
by: Jeff | last post by:
Hey (and thank you for reading my post) In visual web developer 2005 express edition I've created a simple website project.. At this website I want users who register to be able to upload a picture of themselves to their profile... I admit that I'm a newbie... but this is how I understand this:
0
2022
by: Speilman_54 | last post by:
Hi, I'm converting an excel Macro into visual basic 2005 express, as I don't have a copy of VB 6 and trying to make and executable from it, I know this version doesn't have the save file as .exe, but I have a 3rd party software that will convert vb projects into .exe files. My issue is in the the saving of the excel file. The macro bassicly imports a tab delimeted file and manipulates the file and then saves it, as a template to work...
2
1251
by: Matt | last post by:
I'm new to C#, so this really easy to answer for anyone that is adept at this... I'm having trouble saving data from my text boxes on a user form to my SQL database. Everything works fine while in debug mode, the data is saved and reflcted like it shoul be, but once I exit debug mode, all the changes are lost when I reopen the app in debug mode again? I saw the answer to this problem in a video but cannot find the video again? I tried...
0
1191
by: Michelle Monty | last post by:
Hi, I'm trying to create a program where the user can enter check information and the information is saved to 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 the ***** in front of below. Can anyone help me figure out how to fix this error? Thanks for your help. Here's my code: Option Explicit On Option...
0
9487
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9297
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9904
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9735
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7285
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6556
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3828
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2697
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.