我使用下面的代码编制纳斯达克证券交易所的股票代码清单。我使用的是位于此处的CSV文件:http://www.nasdaq.com/screening/companies-by-industry.aspx?exchange=NASDAQ&render=download
当我在Excel中打开CSV文件时,股票代码符号周围没有引号。但是当我运行下面的代码时。返回到我列表的所有股票代码都有引号。为什么是这样?我该如何摆脱引号?
这是我的代码:
Public Shared tickerList As New List(Of String)
Dim compositeList As New List(Of String)
Dim strBuffer As String
strBuffer = Historical_Stock_Prices.RequestWebData(http://www.nasdaq.com/screening/companies-by-industry.aspx?exchange=NASDAQ&render=download)
Dim sReader As New StringReader(strBuffer)
Dim Line_List As New List(Of String)
Do While sReader.Peek >= 0
Line_List.Add(sReader.ReadLine)
Loop
Line_List.RemoveAt(0)
For Each Line In Line_List
compositeList.Add(Line.Split(",")(0).Trim.ToLower)
Next
sReader.Close()
tickerList = compositeList.Distinct.ToList
tickerList.Sort()
答案 0 :(得分:3)
compositeList.Add(Line.Split(",")(0).Trim(New Char() {""""}).ToLower)
答案 1 :(得分:2)
myString = myString.Substring(1, myString.Length -1)
这将删除第一个和最后一个字符。