何必用FSO?
公司主营业务:做网站、网站建设、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。创新互联公司是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。创新互联公司推出松阳免费做网站回馈大家。
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))
楼上的方法很好,不过楼主好像是货币数据吧,逗号像是千分号,然后还有小数点,不妨用:
Format("222,222.00", "######")'#可以根据位数多写点
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
用数组呗。我是用VB6的,不过你会.NET也肯定能看懂。
不是文本文件么?先用Line Input读每行存入数组。再把每行数据用你的","分割,就可以查询了。我写个简单的例子:
'搜索函数,用法Search(标头,序号),返回数据.
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 '行数
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个数据,就用Search("gc",5)即可返回45。