|
I could read and write the line using stream reader and stream writer.But I need to get the values from a column in a text file.After getting those column values,i need to write it in csv format..how i do this?
C.Sridevi
|
|
|
|
|
Hi,
Here is how to read the file in one chunk (very fast):
<br />
Dim inString As String<br />
Dim stringArray() As String<br />
<br />
fileReader = New System.IO.StreamReader(FileName)<br />
inString = fileReader.ReadToEnd()<br />
fileReader.Close()<br />
stringArray = inString.Split(vbLf)<br />
You will then have to parse each line, in stringArray, separating fields at the relevant points.
That is where you will have to do the work.
What you have asked for does not have a quick and easy answer.
Read up on CSV file formats via google then apply your VB .Net knowledge to parsing each line.
Hope this helps
You always pass failure on the way to success.
|
|
|
|
|
There is no need to write a parser to split the lines into a string array. Look at the Microsoft.VisualBasic.FileIO.TextFieldParser class. It will parse fixed width or CSV text files a line at a time.
|
|
|
|
|
Thanks for that.
Oh man - I wrote a csv classs to read and write csv files
I guess I learnt about csv files in the process though
You always pass failure on the way to success.
|
|
|
|
|
Hi All,
How can I call the existing libraries containing unmanaged C++ classes in a vb.net project.
Thanx In Advance.
Paramhans Dubey.
|
|
|
|
|
If they are in dlls, you can p/invoke them. www.pinvoke.net[^]
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi Christian,
Thanx for your help.
Paramhans Dubey.
|
|
|
|
|
I am working in DataGridView. if 40 row is selected i want to show the 40th row to the user automatically without scrolling with mouse.
some one solve the problem plzzzzzzzzzzzzzzz
sumit
|
|
|
|
|
rahul sumeet wrote: some one solve the problem plzzzzzzzzzzzzzzz
I went to teh documentation of the DataGridView and looked through the properties list, and in about 15 seconds I found the FirstDisplayedScrollingRowIndex property. That sounds like it might do what you want.
|
|
|
|
|
I have written code to upload single file to FTP Server using FTPWebRequest class of VB.Net 2005.
Now I want to create folder on FTP server and then upload multiple files into it.
Just tell me how to create folder on FTP Server using FTPWebRequest class or any other method in vb.net 2005.
|
|
|
|
|
hgs24shravgi wrote: I have written code to upload single file to FTP Server using FTPWebRequest class of VB.Net 2005.
Now I want to create folder on FTP server and then upload multiple files into it.
It's done just about the exact same way to uploaded a file. Just change the Method of the FtpWebRequest object you create, then execute it with the GetReponse method.
Dim request As FtpWebRequest = DirectCast(WebRequest.Create("ftp://someurl"), FtpWebRequest)
request.Method = WebRequestMethods.Ftp.MakeDirectory
Dim response As FtpWebResponse = DirectCast(request.GetRseponse(), FtpWebResponse)
Debug.WriteLine("MKD response: " & repsonse.StatusDescription)
response.Close()
|
|
|
|
|
I am able to upload and download single file using demo on this URL -
http://www.codeproject.com/cs/internet/SimpleFTPDemo.asp
I converted that code to VB.Net
But now I want to upload and download one complete folder which may contain sub folders.
So i want to know how to download complete folder
|
|
|
|
|
You have to download the files one at a time, and also see what subdirectories are in there, navigate them in your code and download the files in those, one at a time.
|
|
|
|
|
Dear All,
I am using vb.net and creating a simple application like wordpad.I used the Rich text box control as the platform.I can insert the picture in Rich Text box control,But my problem is thai i can't save the created file with the inserted picture only text content are saved.I choose the save option in (*.Doc)format.Please help me i am new in .net technology.
|
|
|
|
|
Hello,
If you have image in a Rich Text Box, you may use following line of code to save it with image-
RichTextBox1.SaveFile("C:\FileWithImage.rtf", RichTextBoxStreamType.RichText)
You may save this data directly to RTF file using .rtf extension. This rtf file can be opened in MS Word or can be loaded in RichTextBox again using LoadFile method.
I hope this helps .
-Dave.
Dave Traister,
ComponentOne LLC.
www.componentone.com
|
|
|
|
|
Thanks Sir,
Your code helped me to solve my problem.I hope same kind of Response in next time.
Pawan Nepal
Wlink Tech.
Kathmandu, Nepal
|
|
|
|
|
Private Sub bttnGenerate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnGenerate.Click
Using Connection As New SqlClient.SqlConnection(ConnectionString)
Connection.Open()
SqlCmd.Connection = SQLConnection
SqlCmd.CommandType = CommandType.StoredProcedure
SqlCmd.CommandText = "Execute spr_ADB ('" & txtBranchCode.Text & "','" & txtGroup.Text & "','" & txtAccount.Text & "', '" & txtFrom.Text & "','" & txtTo.Text & "', ' ', ' ', ' ', ' ', ' ')"
SqlCmd.Connection = Connection
frmADBViewer.Show()
End Using
End Sub
i'm using this code to pass parameters for my stored procedure....
it work but cyrstal report is asking parameters and login credentials.
please help me on this...
what should i do...
|
|
|
|
|
marvinmichael wrote: i'm using this code to pass parameters for my stored procedure....
That is NOT how to pass parameters! You are passing a security nightmare. That code is riddled with injection into the SQL making it extremely vulnerable to a SQL Injection Attack.
SQL Injection Attacks and some Tips on How to Prevent Them[^]
Try something along these lines
SqlCmd.CommandText="spr_ADB"
SqlCmd.CommandType=CommandType.StoredProcedure
SqlCmd.Parameters.AddWithValue("@branchCode", txtBranchCode.Text)
...
It still isn't perfect as you don't validate the text before passing it to the SQL Server, but it is a start in the right direction.
|
|
|
|
|
Colin Angus Mackay wrote: That is NOT how to pass parameters! You are passing a security nightmare. That code is riddled with injection into the SQL making it extremely vulnerable to a SQL Injection Attack.
It is amazing how many people do that...
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
Guys this f*** .resx is always my proble since i migrate from vb6 to vb.net.. every i use another computer which i can't avoid.. because i work on my client and at the same at office i end up with .resx error... what really .resx means..
|
|
|
|
|
What's the error??
.resx files are used to store resources that get compiled into your .EXE. You may have a corrupted form or project.
|
|
|
|
|
Sir Dave may it cause by copying one object from one for to another.. because i always do it.like copying toolstrip, menustrip, combo, etc.. is it right to do it that way? Should i need to create new object that in need in every new form i made?
|
|
|
|
|
What you're doing shouldn't corrupt the .resx file. But, then again, if you don't have the latest service pack installed, there's no telling. You might be forced to recreate the form from scratch. Do not copy the controls from the old form, but drag and drop new ones. You can copy and paste the code form the old form though.
|
|
|
|
|
I have a multi-threaded app where objects are enqueued by one thread and dequeued by the other (for sanity sake I'll call them the writer and reader threads).
The writer event is externally triggered and it is imperative that the trigger event is not delayed (which is why it is in its own thread).
There is an AutoResetEvent that is set to tell the reader thread that there are events to read. The problem is that if another writer event occurs while the reader is processing the queue it gives a System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
So - two questions:
(1) Is there a better architecture for this kind of situation
(2) If not, how do I prevent the error - i.e. how can the writer tell the reader to give is a rest for a while because more writing is going to be done?
(I could give code but it'd probably just confuse matters...)
|
|
|
|
|
Duncan Edwards Jones wrote: (1) Is there a better architecture for this kind of situation
Yes.
:: Use the Dequeue method instead of looping through the queue.
:: Lock the code that is queueing and the code that is dequeueing, so that they can't occur at the same time.
:: Only lock the code that is dequeueing the item, not the entire loop.
When you are using data in more than one thread, you have to use locking to prevent data corruption. The error message you are getting is because the collection has a built in protection that has detected that you have changed the collection in one thread while looping it in another.
---
single minded; short sighted; long gone;
|
|
|
|