|
Yes... I tryed just with the StreamReader, and it does not work, I have not thinked about StringReader. So I will se it...
Thanks
|
|
|
|
|
Hi,
Since String are immutable, any changes you make to the String, like removing a line from it, will result in a copy of the string being created that includes the change you made, then the original string is abandoned and, later, cleaned up by the garbage collector.
Holding a 300K string in memory doesn't sound like a good use of resources. Why the large string?
RageInTheMachine9532
|
|
|
|
|
Hi,
I have a .txt file, and it is very big, my application needs to change this file at any time, and to open edit and save it will result in a long time token, so I think it is better to copy it to a variable, make the changes to the variable, and in the end of the program, it could write again.
I do not know if there is a way to rewrite the file just where it has changed, and do not write all the file again, them it will be much better.
If you could help me...
Thanks
|
|
|
|
|
What's in this file? Is it a text document? flat database? Worlds Largest Configuration (.INI) file?
Maybe there is a better way to do it, but it depends on the what the data is and what your doing to manipulate it.
RageInTheMachine9532
|
|
|
|
|
Hi,
It is a text document, so i read it, edit it and them it write again, but jsut write wher it has changed, the it wil be faster...
I do not know with there is a direct way to edit it, or if I have to put it in a variable anyway...
Any ideas...
|
|
|
|
|
OK. It looks like that a String() is the best method then. It sounds like the problem you have now is the speed at which the string is read from or written to the file. I've come up with a partial implementation of a text editor with some code that is the fastest text file reader/writer that I can come up with. It reads/writes 500K in less than 0.05 seconds on my machine.
Here's the code snippet for reading and writing the file:
Private Sub mnuFileOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileOpen.Click
If ofdOpenFile.ShowDialog = DialogResult.OK Then
fileName = ofdOpenFile.FileName
Dim openFile As New StreamReader(fileName)
txtEdit.Text = openFile.ReadToEnd()
openFile.Close()
End If
End Sub
Private Sub mnuFileSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileSave.Click
If Not fileName.Equals(String.Empty) Then
Dim saveFileWriter As StreamWriter = File.CreateText(fileName)
Dim strReader As New StringReader(txtEdit.Text)
saveFileWriter.Write(strReader.ReadToEnd)
saveFileWriter.Flush()
saveFileWriter.Close()
strReader.Close()
End If
End Sub
If you want the entire sample project, send me an email with an address to reply to.
RageInTheMachine9532
|
|
|
|
|
Has anyone else had problems with the Application.DoEvents statement? I have a VB.net written DLL that throws the ubiquitous "Object reference not set..." error on a couple of machines. I can't duplicate the error on my desk or on other machines.
When I put code in to trace down exactly which statement it's on when the error hits, it's a DoEvents statement. I mostly put those in to give the calling apps time to process other events, so they aren't all critical. So, in an attempt to narrow it down, I removed the offending statement. The error hit again but this time on the next DoEvents statement it found in the code.
This has got me completely puzzled. Normally, when something happens on one machine and not one all, I check to make sure any referenced DLL's are the same. They are. This DLL calls 2 COM objects and 1 .NET DLL and all of those references are identical in version.
I know the error normally means that someone forgot a "NEW" statement or an object was inadvertantly set to Nothing, but I can't find any object where that would make sense. If that was the case, the DLL wouldn't run cleanly anywhere, but it does run OK on some machines, including in the development environment.
Any ideas would be greatly appreciated.
|
|
|
|
|
Not sure why your application object isn't instantiated, but you could also try the tell the thread to whait a brief moment.
System.Threading.Thread.CurrentThread.Sleep(500)
|
|
|
|
|
Hi.....
i want to deploy my project by creating setup.Can you help me how to create setup which includes the dot net framework.Let me know the procedure how to include Dotnet FrameWork in my project's msi file.Let me know the procedure to deploy my project on system which does not have dotnet framework.How to install the required supports to run my vb .Net Program.
Thanks for your help.
Payal Sheth
|
|
|
|
|
Hi,
I'm new to programming and need help. I'm trying to design an application that will allow end users to search a diary for bookings; make a booking if available; and then update a database system.
I'm having difficulty in designing/coding the diary section of the application.
Any ideas and help would be much appreciated.
|
|
|
|
|
Hi Martyn. That is a very broad request for help. How new are you to programming in general, and to .NET programming in particular? Would you be helped at this point to get a list of recommended reading on the subject?
As you go along, if you get to a specific point in your coding that is causing difficulty, or have a question about a more specific area in your development, post it and I'm sure folks will try to help. It's just a tough thing to answer such a broad question, beyond offering links you could visit or recommendations for books, that sort of thing.
|
|
|
|
|
Hi
How to make property indexers in VB .NET...
Against my will, I am standing beside my own shadow!
-------------------
Therez No Place like ... 127.0.0.1
|
|
|
|
|
The following should work:
Public Property Notes(ByVal index As Integer) As String<br />
Get<br />
Return m_Notes(index)<br />
End Get<br />
Set(ByVal Value As String)<br />
m_Notes(index) = Value<br />
End Set<br />
End Property
The when you're using the property:
myClass.Notes(2) = "Some message!"
Hope this helps.
Dan Morris
|
|
|
|
|
he he he he....
I want to do
myClass(2) = "Some message!"
Anyway, thanks for your time... I appreciate it
fadee
-------------------
Therez No Place like ... 127.0.0.1
|
|
|
|
|
I think you want to assign a property as Default . Try this page on MSDN[^].
|
|
|
|
|
Meeeeeeeerci
-------------------
Therez No Place like ... 127.0.0.1
|
|
|
|
|
Add a "Default" to that property and then you can call it as myClass(2) = "SomeMessage".
Default Public Property Notes(ByVal index As Integer) As String
Get
Return m_Notes(index)
End Get
Set(ByVal Value As String)
m_Notes(index) = Value
End Set
End Property
|
|
|
|
|
somebody please about how to store a video files and play it into a web application (just like Yahoo!Movies site)
i'm kinda new on this thing
given2fly
|
|
|
|
|
What books or articles have you already read/researched to learn about web development?
What you're describing could be as simple as:
1) - create files in .avi, .mp3, .mov, or other video format
2) - store those files in a directory on a web server
3) - create simple html page (wouldn't really need asp.net for this) with <a href="xxxxxx.avi">MyFile</a> kinds of tags.
|
|
|
|
|
I am creating an MDI applicalion using VB.NET and I need to know how to restrict opening only one instance of each child form. Currently everytime I click on a child form it opens a new instance of it. If an instance of a particular child form is open and I click to open again it shouldn't let me.
Your HELP is greatly appreciated.
|
|
|
|
|
Hi. I'm not sure I understand what you mean. In your MDI application, are you clicking a menu item to instantiate a child form? If that's the case, then it should be simple in your parent form to maintain a private variable that can hold the child form. In the menu item code to open the child form, check if the private variable is nothing ; if it is, set it to a new instance of your child form. If it isn't, then don't create a new child form instance, just use the Activate() method of the child form in the private variable to bring it to front. Something like this:
...
Private _childForm as MyChildFormClass = nothing
...
Private Sub OpenMyChildForm()
If (_childForm Is Nothing) Then
_childForm = new MyChildFormClass()
_childForm.Show()
Else
_childForm.Activate()
End If
End Sub
|
|
|
|
|
Anybody out there who knows how to save Documents created in Ms Word or any other Word Processor in a database instead of a folder and more specifically in MsAccess, using VB.NET?
Also, I need to save different kind of Images or pictures in a database (MsAccess)as well.
Your help is greatly appreciated and desperately needed. Thanks in advance
Ted
|
|
|
|
|
respected sir/madam,
please tell me how to save and scan image with VB6 acting as a front end and Access as a backend.note that i have to use a Adodb control
praveed
PRAVEED
|
|
|
|
|
When I use the notify icon on my form how can i get it to keep the form hidden when the program starts up?
|
|
|
|
|
You can implicitly open a form without showing it.
I keep all pictures i use in one form and use them from there:
Me.Icon = frmPictures.Icon
or
Me.tvwArticles.ImageList = frmPictures.imlNodePics2
Hope this helps
Grtz, Guus
|
|
|
|