473,563 Members | 2,884 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(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load

RichTextBox1.Lo adFile("C:\Outp utFolder\lol", RichTextBoxStre amType.PlainTex t)
On Error Resume Next
RichTextBox1.Sa veFile("C:\Outp utFolder\lol", RichTextBoxStre amType.PlainTex t)

End Sub

Private Sub Form1_FormClosi ng(ByVal sender As Object, ByVal e As System.Windows. Forms.FormClosi ngEventArgs) Handles Me.FormClosing

RichTextBox1.Sa veFile("C:\Outp utFolder\lol", RichTextBoxStre amType.PlainTex t)

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 1384
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(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load

RichTextBox1.Lo adFile("C:\Outp utFolder\lol", RichTextBoxStre amType.PlainTex t)
On Error Resume Next
RichTextBox1.Sa veFile("C:\Outp utFolder\lol", RichTextBoxStre amType.PlainTex t)

End Sub

Private Sub Form1_FormClosi ng(ByVal sender As Object, ByVal e As System.Windows. Forms.FormClosi ngEventArgs) Handles Me.FormClosing

RichTextBox1.Sa veFile("C:\Outp utFolder\lol", RichTextBoxStre amType.PlainTex t)

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
6955
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, any comments/suggestions would be greatly appreciated.
2
4221
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 Visual Basic.Net as a springboard for studying VBA. I use Office 2000 and would like to use VBA as a tool to customize it. I have zero...
4
2425
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 NOT from me. He wants a manual that is NOT a handholding tome on how to write a program, but instead is rather a complete language description in...
1
2135
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 send to the database a script file to run, as done by: "@FullPath\FileName" in SQL PLUS ? If not, then I need your help with something else: I tried...
13
1306
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 'About' screen info): Microsoft Visual Basic.Net Microsoft. Net Framework 1.1.4322 SP1
11
2115
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 Reserve unit.) I need a textbook recommendation for a particular need. As I have delved into ASP.Net I find that I want to teach the course by...
4
1224
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 hold of this new language and framework now. I was wondering if someone can suggest a good (and cheap) book for me for an intermediate programmer....
2
4868
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 remove (to start over from scratch) the installation. The messages popping up after choosing one of these two alternatives Repair/Remove Visual...
8
4466
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 Basic? When I search through Google it seems to me that most of the introduction think that Visual Basic is pre-installed. But I did not found a...
97
5451
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 the first place. Anyone else heard about this development? The Master
0
7664
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...
0
7583
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...
0
7885
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7638
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7948
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...
0
6250
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5213
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...
1
2082
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
1
1198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.