何必用FSO?
公司主營業(yè)務:做網(wǎng)站、網(wǎng)站建設、移動網(wǎng)站開發(fā)等業(yè)務。幫助企業(yè)客戶真正實現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競爭能力。創(chuàng)新互聯(lián)公司是一支青春激揚、勤奮敬業(yè)、活力青春激揚、勤奮敬業(yè)、活力澎湃、和諧高效的團隊。公司秉承以“開放、自由、嚴謹、自律”為核心的企業(yè)文化,感謝他們對我們的高要求,感謝他們從不同領域給我們帶來的挑戰(zhàn),讓我們激情的團隊有機會用頭腦與智慧不斷的給客戶帶來驚喜。創(chuàng)新互聯(lián)公司推出松陽免費做網(wǎng)站回饋大家。
text1
.text中文件夾路徑要包含"\"的結尾
Dim
fn
as
string,all
as
string
fn
=
dir(Text1.Text,vbdirectory)
do
while
len(fn)0
if
fn".."
and
fn"..."
then
all
=
all
vbcrlf
fn
fn
=
dir
loop
msgbox
text1.text
"目錄下所有的目錄為:"
all
新建一個按鈕,取名Command1;新建一個文本框,取名Text1,然后雙擊Command1,輸入如下代碼:
Private?Sub?Command1_Click()
Dim?i?As?Integer
Dim?s?As?String
For?i?=?1?To?Len(Text1.Text)
If?Mid(Text1.Text,?i,?1)??","?And?Mid(Text1.Text,?i,?1)??","?Then?'截取一個字符并判斷其是否為英文括號或中文括號
s?=?s??Mid(Text1.Text,?i,?1)?
'如果不是,則寫入另一個字符串中
End?If
Next?i?
MsgBox?s???????'報告結果
End?Sub
啟動程序,就可以了
如果不懂,可以追問
str=split(textbox.text,",")
a=str(0)
b=str(1)
...
x=str(ubound(str))
樓上的方法很好,不過樓主好像是貨幣數(shù)據(jù)吧,逗號像是千分號,然后還有小數(shù)點,不妨用:
Format("222,222.00", "######")'#可以根據(jù)位數(shù)多寫點
Option Explicit
Private Sub Command1_Click()
Dim a As String
Dim aa As String
Dim i As Integer
a = "asdf,235684"
i = InStr(a, ",") '找到","的位置
aa = Left(a, i - 2) + ","
aa = aa + Right(a, Len(a) - i - 1)
Text1.Text = aa
End Sub
用數(shù)組唄。我是用VB6的,不過你會.NET也肯定能看懂。
不是文本文件么?先用Line Input讀每行存入數(shù)組。再把每行數(shù)據(jù)用你的","分割,就可以查詢了。我寫個簡單的例子:
'搜索函數(shù),用法Search(標頭,序號),返回數(shù)據(jù).
Private Function Search(ByVal Section As String, ByVal Index As Integer) As String
Dim fNum%, Lines%, temp%, Str As String
ReDim Data(0)
fNum = FreeFile()
If Dir("C:\1.txt") = "" Then Exit Function '文件路徑和文件名你自己改
Open "C:\1.txt" For Input As #fNum
Do While Not EOF(fNum)
Lines = Lines + 1 '行數(shù)
Line Input #fNum, Str
ReDim Preserve Data(Lines)
Data(Lines) = Str
Loop
Close #fNum
If Lines 0 Then
Dim tmp() As String
For temp = 1 To UBound(Data)
tmp = Split(Data(temp), ",") '分割
If tmp(0) = Section Then
Search = tmp(Index - 1) '因為從0開始所以-1
Exit Function
End If
Next
End If
End Function
比如你要“gc“開頭的第5個數(shù)據(jù),就用Search("gc",5)即可返回45。