|
-
Aug 24th, 2001, 08:07 AM
#1
Thread Starter
New Member
new programmer new project
im starting a new project, and im also quite new to VB and am lacking documentation until sunday. Anyways im working on making a simple html editor and im just needed help on opening/saving html documents through vb, this is a sorta notepad+ type project so im not doing any WYSIWYG display i just need to get open/save code that works with vb7 and reads html nicely... thanks if you can help
-
Aug 24th, 2001, 08:11 AM
#2
Retired VBF Adm1nistrator
Add a TextBox, and then try :
VB Code:
Open "c:\something.html" For Binary As #1
Text1.Text = Input(Lof(1), 1)
Close #1
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Aug 24th, 2001, 08:19 AM
#3
Member
And to save...
VB Code:
Open "c:\something.html" For Output As #1
Print #1, Text1.Text;
Close #1
BTW, plenderj, why Binary? HTML is just ASCII/Unicode text.
-
Aug 24th, 2001, 08:23 AM
#4
Retired VBF Adm1nistrator
Binary's faster as far as I know
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Aug 24th, 2001, 08:27 AM
#5
To open a file for binary instead of for input does not give you any performance boost.
-
Aug 24th, 2001, 09:26 AM
#6
Thread Starter
New Member
still need help
when i try both codes im getting "The name 'Open' is not declared. The file I/O functionality is available as runtime routines in the Microsoft.VisualBasic namespace." now if i wernt very new and very much lacking documentation for this version of vb then i would have this fixed but i still need some help thanks
-
Aug 24th, 2001, 09:27 AM
#7
Member
Your VB version in your profile says "7.0." Are you using VB.NET?
-
Aug 24th, 2001, 09:32 AM
#8
Thread Starter
New Member
well
im using Visual Studio.net beta 2 not the sdk or anything but actualy 7.0 vs beta 2
-
Aug 24th, 2001, 09:33 AM
#9
Member
In that case, you might want to try posting in the .NET forum instead. Many of us don't know .NET yet.
-
Aug 24th, 2001, 09:46 AM
#10
The Microsoft.VisualBasic namespace in VB.Net still supports the Open, Close, Get, Put, Input, Print and related statements.
You can also use the .Net Framework stream-based file I/O found in the System.IO namespace.
VB Code:
Dim fs As FileStream
fs = new FileStream("c:\myfile.htm", FileMode.OpenOrCreate, FileAccess.Read)
Dim sr As New StreamReader(fs)
TextBox1.Text = sr.ReadToEnd()
To write to a file:
VB Code:
Dim fs As FileStream
fs = new FileStream("c:\myfile.htm", FileMode.OpenOrCreate, FileAccess.Write)
Dim sw As New StreamWriter(fs)
sw.Write(TextBox1.Text)
Best regards
-
Aug 24th, 2001, 04:02 PM
#11
Thread Starter
New Member
weelll im still having issues with that code too, you sure thats all functional in beta2 of visual studio.net?
-
Aug 25th, 2001, 04:20 AM
#12
Yes I am. But as you can see in my previous post this methods are part of the System.IO namespace which you have to set a reference to.
In the Solution Explorer right click the Reference node and click Add Reference.
Pick System.IO.dll in the list and add the following line in your code (under the other Import statements)
If you don't add the Import statement you'll have to use the full name of the namespace.
VB Code:
Dim fs As System.IO.FileStream
fs = new System.IO.FileStream("c:\myfile.htm", _
System.IO.FileMode.OpenOrCreate, _
System.IO.FileAccess.Read)
'....
But you still have to set a reference to the namespace.
Best regards
Last edited by Joacim Andersson; Aug 25th, 2001 at 04:27 AM.
-
Aug 25th, 2001, 08:32 PM
#13
Thread Starter
New Member
rr yes works, sorta, not really im going to wait for my wonderful documentation to return to me thanks anyways
-
Feb 20th, 2003, 09:20 AM
#14
Addicted Member
My ready made code.
Goto www.planetsourcecode.com and search for "wicked" without quotes in the Vb section. Then get the text editor base. It functions exactly the same as the open,save,save as in notepad. Also, if your text is unchanged and the user attempts to exit the editor, the user will be prompt to save the unchange file, just like in notepad. Oh yes! Please remember to aknowledge me cos i'm the programmer...
Unignal Software Team Developer
-------------------------------------------
Current Project:
Noter Light
-------------------------------------------
http://www.unignal.sg.tf
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|