473,403 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

help on a command that will only run on first start of program

20
this is my code

Private Sub Form1_load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

RichTextBox.LoadFile("C:\\filenotes", RichTextBoxStreamType.RichText)

End Sub


Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As

System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing

RichTextBox.SaveFile("C:\\filenotes", RichTextBoxStreamType.RichText)

End Sub


when i open my app it comes up with an error , because it trying to load a file that is not there , it there a 'runonce' command which will only run on the first ever run of the program ( a command to create the file "C:\\filenotes") . This would solve my problem

( the code is very basic generally because i'm new to vb)


thanks for your time / help
Feb 29 '08 #1
2 855
kadghar
1,295 Expert 1GB
when i open my app it comes up with an error , because it trying to load a file that is not there , it there a 'runonce' command which will only run on the first ever run of the program ( a command to create the file "C:\\filenotes") . This would solve my problem

( the code is very basic generally because i'm new to vb)


thanks for your time / help
A lazy solution will be adding

Expand|Select|Wrap|Line Numbers
  1. on error resume next
at the begining of the sub, so if it doesnt find the file, it'll skip that line, and wont stop the app.

I'd recomend you that also write
Expand|Select|Wrap|Line Numbers
  1. on error goto 0
in some point where you want the code to start showing you the errors again.

HTH
Feb 29 '08 #2
Killer42
8,435 Expert 8TB
It seems as though the more sensible approach would be to have your application's startup code check whether the file exists and if not, create it. That way, it won't matter whether it has been run before.
Mar 3 '08 #3

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

Similar topics

2
by: Parker.Jim | last post by:
I need to write a program which performs word subsitutions on a text file. The program should input the names of three text files: the source file that will be "edited", a text file that contains...
4
by: Kevin Mansel via .NET 247 | last post by:
Ok, basically this is my problem. I'm building a console app tocall a dos program. So i'm using the Shell command to call theprogram, now depending on what happens, I want to read theoutput that...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
66
by: genestarwing | last post by:
QUESTION: Write a program that opens and read a text file and records how many times each word occurs in the file. Use a binary search tree modified to store both a word and the number of times it...
2
by: pvadhi07 | last post by:
Hello Everyone, I hope you can help me. My problem is I have to run server programs from multiple Linux machines, but I will run them remotely from one machine. That is I will run program1 on...
12
by: adamurbas | last post by:
ya so im pretty much a newb to this whole python thing... its pretty cool but i just started today and im already having trouble. i started to use a tutorial that i found somewhere and i followed...
2
by: rookiejavadude | last post by:
I'm have most of my java script done but can not figure out how to add a few buttons. I need to add a delete and add buttong to my existing java program. Not sure were to add it on how. Can anyone...
2
by: =?Utf-8?B?SnJ4dHVzZXIx?= | last post by:
I just started using Windows Live OneCare, I had been using Norton, but was unable to fix the problems I was having. I have yet been unsuccessful with OneCare as well. I keep getting the same...
5
by: dm3281 | last post by:
I'm really starting to hate writing services -- or trying to, anyway. Why do I need to rename my project to the service name? Why do I need to set the "ServiceName" property to my service name?...
0
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
Oralloy
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,...
0
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...
0
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...
0
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...

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.