|
Sorry for the troublesome! This is some of my code which i only manage to get title as return. May i have some advice on it?
Private Function ReadTextFile(ByVal sFileName As String) As String
Dim s As String = String.Empty
Try
Dim oFile As FileStream = New FileStream(sFileName, FileMode.Open, FileAccess.Read, FileShare.Read)
Dim oReader As StreamReader = New StreamReader(oFile)
s = oReader.ReadLine()
oReader.Close()
oFile.Close()
ReadTextFile = s
Catch
ReadTextFile = "Unable to open file."
End Try
End Function
|
|
|
|
|
Your problem is that you're only reading the first line of the file.
The ReadLine call needs to be a recurrent call, based on the return value of the method.
e.g. (from MSDN)
<br />
Dim input As String<br />
input = sr.ReadLine()<br />
While Not input Is Nothing<br />
'Do something with the input<br />
<br />
'Read the next line of input<br />
input = sr.ReadLine()<br />
End While<br />
This will continue to read the file until there is no further input returned by the ReadLine() call. Then you'll have to compare the returned input string to whatever you want to catch, either using a regex or a string constant (in the case of a marker string or something that won't change) to get the particular peice of info you're after. I would add do it something like this...
<br />
Dim input As String<br />
input = sr.ReadLine()<br />
While Not input Is Nothing<br />
<br />
If (input.CompareTo(stringConstant) = 0)<br />
'do whatever with the data<br />
input = Nothing<br />
Else<br />
input = sr.ReadLine() <br />
End If<br />
End While<br />
|
|
|
|
|
Thank u, it really help a lot!
|
|
|
|
|
Hi all,
I have created application for uploading huge chunk file (min 1gb) to server(CONTENT MGMT SERVER).
File Size TIME
1.4 GB 22 Minutes
3.17 GB 32 Minutes
I am reading 10MB chunks for each partial write and utilizing maximum of 25 threads running at any point of time during execution. Can anyone help me to improve performance application.
I would appreciate, If anyone give me suggestion to improve performance of application.
Thanks,
Vijay Kumar
Email#jaydotnet@gmail.com
vijay
|
|
|
|
|
jaydotnet wrote: Can anyone help me to improve performance application.
Upgrade to an OC48 line? Warning! Can be cut by any idiot with a backhoe.
jaydotnet wrote: 10MB chunks for each partial write and utilizing maximum of 25 threads
25 threads? For what?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi Dave,
I appreciate your reply.
I am using window application for uploading this huge data to content management server. when i try to transfer 1 huge chunk data (more than 1 gb) it take more than 1 hr to transfer. content mgmt server reads data byt 16kb and buffers in internal memory then writes to server. content management server group suggested us to read file into multiple slice and upload file using multi-threading(max 25 at any time). After doing this we had some performance improvement but no upto expectation.
if you need i can post my code.
thanks
Vijay
|
|
|
|
|
I see. It would appear that this is the best performance you're going to get. Not because of your code, but because of performance issues on the server side. If you're really good with a protocol analyzer, you can watch the traffic go by and look at the times it's taking for acknowledgement traffic to come back from the server.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I need to be able to search a DataTable for a non-primary key field. I'd assume the best way is just to populate a dataset and fill the table. But how do I search the table for non-primary key values?
Nathan Lindley
.NET Aficionado
|
|
|
|
|
Something along the lines of
<br />
for each datarow in datatable<br />
if datarow.coumn(i) = searchvalue then<br />
return what you want<br />
end if<br />
next<br />
Mike Lasseter
|
|
|
|
|
I had played around with iterating the DataTable for the row, but was unsuccessful. I guess i'll play around with it a little more. Thanks.
Nathan Lindley
.NET Aficionado
|
|
|
|
|
Dim dr() as DataRow
dr = datatable.Select("FieldName = 'something'")
dr will be an array of rows from the datatable that match the query.
|
|
|
|
|
You can't assign a dataRow to an Array of datarows...i think the error says something like '1 dimensional array System.Data.DataRow cannot be converted to System.Data.DataRow' ... thanks for the response though.
Nathan Lindley
.NET Aficionado
|
|
|
|
|
It works. I've used it many times. You must declare the DataRow variable as an array. **use the parentheses after the name of the variable**
Dim dr() As DataRow
The select function of the DataTable class will return an array of data row objects.
I am using .NET 2005
|
|
|
|
|
Good call with the casting it as a DataRow array.
Nathan Lindley
.NET Aficionado
|
|
|
|
|
I am wondering what the best approach is to consume a method that occurs when a button is clicked on a separate form. The situation is that form1 has an add record button that shows form2. after form2 is filled out/submitted, I need to fire the clear event (triggered by a button on form1), to clear out form 1. I would like to keep the button_click method private as well.
TIA
Nathan Lindley
.NET Aficionado
|
|
|
|
|
A delegate is what you need here.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I was thinking something along those lines, thanks for the input, i'll proceed in that direction.
Nathan Lindley
.NET Aficionado
|
|
|
|
|
Another way to do this would be to implement an MVP or similar (MVC, Passive Screen, Supervising Controller etc.) pattern. That way you could raise the event from the view, into the associated presenter, which can Notify through a model to anywhere in the application that uses that model. Making the event not dependant on the form.
Of course, this might not be viable. It's something to think about though...
Take a look here[^] for more info on the patterns
|
|
|
|
|
Hi,
I have to write in VB.NET something like the ActiveX Controls developed in VB6. These was .ocx files and in Labview 7.1 they worked ok. I have read a lot of articles, also "Exposing Windows Forms Controls as ActiveX controls", but,in Labview, I don't find my activex in the list of availables. I think there is also a problem of registration.
Many thanks for any suggestion about.
Garraty
|
|
|
|
|
.NET Assmeblies that export COM functionality need to be registered on the machine using REGASM, which comes with the .NET Framework, not REGSVR32.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I'm looking for a midi piano class that is written in vb.net. I have found plenty in VB6 and C, but not written in Vb.net. The class should be able to play notes that I can call from the form with parameters for note (e.g. "C" in octave 4) and for duration (millisecons). The grand piano sound of General MIDI is enough.
Here are two examples. Can someone translate one of them in VB.net? I would be most grateful!
http://www.xtremevbtalk.com/showthread.php?t=36582& (scroll few posts down)
http://www.a1vbcode.com/app-2951.asp (download link)
|
|
|
|
|
You can modify this vb.net code into a class,
Take a look here:
http://www.tomgroves.net/projects/vbmidi/[^]
Notes:
'Grand Piano Midi Patch Number is 0
'Octave 4 "C" Pitch (Midi Note Number) 108, Freq = 4,186.0090448096 Hz
Progload
|
|
|
|
|
Hey, thanks a lot! I'll try that tomorrow. By the way, is it possible to play two notes at the same time?
|
|
|
|
|
re infecta wrote: is it possible to play two notes at the same time
In Sequence, Yes, just send the new message right after the first message.(just don't forget to close all the messages when your done with them.)
Progoad
|
|
|
|
|
OK! The code worked very well.
One question still: How to open two midi channels and play them at the same time: one playing grandpiano and the other playing percussion (drum hit)?
|
|
|
|