VB 2010 - 读取csv文件 [英] VB 2010 - reading a csv file

查看:89
本文介绍了VB 2010 - 读取csv文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网上看了这个,我发现它们没那么有用,我知道如何读取一个normel文本文件并将其放在文本框中,但我希望能够读取csv文件一个列表框。



例如。 (CSV)

hi,hi2,hi3



例如。 (列表框)

hi

hi2

hi3



这将是使用.csv而不是.txt



我想知道是否有人可以帮我实现这个目标?如果是这样,请解释它是如何工作的

解决方案

字符串类有一个split方法。您可以使用File.ReadAllLines读取文件并获取字符串数组。每个字符串,你可以拆分,以获得一个单独的字符串数组。



Code Project上还有一个CSV类...

ive looked on the web for this and,I find them not that helpful,I know how to read a normel text file and put it on a textbox, but i want to be able to be able to read the csv files in a listbox.

for example. (CSV)
hi,hi2,hi3

for example. (listbox)
hi
hi2
hi3

and this will be using the .csv not the .txt

I was wondering if anyone can help me achieve this goal? and if so please explain how it works

解决方案

The string class has a split method. You can read a file with File.ReadAllLines and get a string array. Each string, you can split on the , to get an array of individual strings.

There''s also a CSV class on Code Project somewhere...


这篇关于VB 2010 - 读取csv文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆