473,498 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

need help visual basic 9

20 New Member
i wont a text file to load into a rich text on box on load , then save when the form closes. my problem has been creating the text file , i am very new for visual basic and could use some help this is my attempt on this.

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

RichTextBox1.LoadFile("C:\OutputFolder\lol", RichTextBoxStreamType.PlainText)
On Error Resume Next
RichTextBox1.SaveFile("C:\OutputFolder\lol", RichTextBoxStreamType.PlainText)

End Sub

Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing

RichTextBox1.SaveFile("C:\OutputFolder\lol", RichTextBoxStreamType.PlainText)

when the form is opened for the first time the file has not been created , i thought the the on error resume next would skip it to the next line so the file is created , but not overwritten every time the program is opened .


as i said i am very new to visual basic so please correct or even tell me what i tired to do was rubbish but please help would be very welcome

thanks for your time/help
Rob
May 16 '08 #1
4 1375
Dököll
2,364 Recognized Expert Top Contributor
i wont a text file to load into a rich text on box on load , then save when the form closes. my problem has been creating the text file , i am very new for visual basic and could use some help this is my attempt on this.
Expand|Select|Wrap|Line Numbers
  1.    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  2.  
  3.         RichTextBox1.LoadFile("C:\OutputFolder\lol", RichTextBoxStreamType.PlainText)
  4.         On Error Resume Next
  5.         RichTextBox1.SaveFile("C:\OutputFolder\lol", RichTextBoxStreamType.PlainText)
  6.  
  7.     End Sub 
  8.  
  9. Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
  10.  
  11.         RichTextBox1.SaveFile("C:\OutputFolder\lol", RichTextBoxStreamType.PlainText)
  12.  
when the form is opened for the first time the file has not been created , i thought the the on error resume next would skip it to the next line so the file is created , but not overwritten every time the program is opened .


as i said i am very new to visual basic so please correct or even tell me what i tired to do was rubbish but please help would be very welcome

thanks for your time/help
Rob
Hey buddy!

I don;t know how much help I can be to you, but I added some code tags for you, for visibility.

I use VB 6 a lot; opening a file using Open method seems to be the way to go everytime, here is code regarding text files in VB 6, perhaps you can get an idea there:

http://visualbasic.ittoolbox.com/gro...ng-vb-1419230#

Please write if you need more help!

Dököll
May 17 '08 #2
ooroboo
20 New Member
thanks i think this helped to understand it more , but if possible i would still like for help . i am using vista and its seems to decline access when the programs tries to save the file and comes up a error message . any ideas on this and the first problem?

thanks again for the time/help

rob
May 17 '08 #3
Sick0Fant
121 New Member
i wont a text file to load into a rich text on box on load , then save when the form closes. my problem has been creating the text file , i am very new for visual basic and could use some help this is my attempt on this.

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

RichTextBox1.LoadFile("C:\OutputFolder\lol", RichTextBoxStreamType.PlainText)
On Error Resume Next
RichTextBox1.SaveFile("C:\OutputFolder\lol", RichTextBoxStreamType.PlainText)

End Sub

Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing

RichTextBox1.SaveFile("C:\OutputFolder\lol", RichTextBoxStreamType.PlainText)

when the form is opened for the first time the file has not been created , i thought the the on error resume next would skip it to the next line so the file is created , but not overwritten every time the program is opened .


as i said i am very new to visual basic so please correct or even tell me what i tired to do was rubbish but please help would be very welcome

thanks for your time/help
Rob
One thing I would suggest is to use a Try/Catch block instead of On Error GoTo. Try loading the file. Handle the exception in the catch by Creating the file. Only save the file when you're done with it. Come back if you still have a problem.
May 19 '08 #4
Sick0Fant
121 New Member
thanks i think this helped to understand it more , but if possible i would still like for help . i am using vista and its seems to decline access when the programs tries to save the file and comes up a error message . any ideas on this and the first problem?

thanks again for the time/help

rob
Is the file you're trying to save being used by some other program (e.g., is it opened in Notepad?)
May 19 '08 #5

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

Similar topics

3
6949
by: pix | last post by:
Hello, I would like to start learning Visual Basic, and I was wondering if there are any recomendations to any ebooks, or actual books for that matter. I have my eye on this book by John Smiley,...
2
4212
by: AK | last post by:
I don't want any part of the previous discussion on Visual Basic versus Visual Basic.Net. My query is about using Visual Basic for Applications; and whether it is better to use Visual Basic 6 or...
4
2421
by: Steve Richfie1d | last post by:
I wrote my first BASIC compiler when Bill Gates was going to Lakeside School, and am believed to be the original inventor of the ON ERROR statement. Now, my son wants to learn Visual Basic, but...
1
2120
by: Tom Rahav | last post by:
Hello all! I develop application in Visual Basic .NET and ORACLE database. My question is how do I "send" script file to the database using visual basic .net. Other words, is there any way to...
13
1299
by: jbraly | last post by:
I am BY NO MEANS a developer or a programmer... I just do tech purchases for a school system. A teacher wants about 20 licensse for the following program (He said he got this info from the...
11
2099
by: Larry | last post by:
I will be teaching an eCommerce application development course using ASP.Net after many years of having taught classic ASP. (Course was interrupted by 18 months in the Middle East with my Army...
4
1217
by: Ashish | last post by:
Hi, Can someone recommend a VB.NET book for an experienced VB programmer? I have extensive experience in programming in VB, but lately I decided to try VB.NET too. I think I have pretty good...
2
4859
by: frossberg | last post by:
Hello! I tried to install the Visual Basic.NET Resource Kit (http://msdn.microsoft.com/vbasic/vbrkit/) but obviously something went very wrong and now it sems impossible both to repair and to...
8
4454
by: Frank Callone | last post by:
Until now I programmed a lot with C++ and Java. Now I want (have) to do some programming with Visual Basic. Which software do I need for this ? Which is the best GUI development tool for Visual...
97
5412
by: Master Programmer | last post by:
An friend insider told me that VB is to be killled off within 18 months. I guess this makes sence now that C# is here. I believe it and am actualy surprised they ever even included it in VS 2003 in...
0
7004
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
7167
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
7208
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...
1
6890
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7379
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
5464
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4915
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...
1
657
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
292
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...

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.