Private Sub getvalue(ByVal filename As String, ByRef value() As String)
Dim s As String
Dim ss() As String
Dim linecount As Long
Dim i As Long
Open filename For Input As #1
Do
Line Input #1, s
linecount = linecount + 1
If 3 = linecount Then
ss = Split(s, ",")
For i = 0 To UBound(ss) - 1
value(i + 1) = ss(i)
Next i
Close #1
Exit Sub
End If
Loop While Not EOF(1) '85127
Close #1
End Sub
Private Sub Command1_Click()
Dim a(1 To 100) As String
getvalue CommonDialog1.filename, a
Text2.Text = a(8) & "," & a(5) & "," & a(1) * 10000 & "," & a(2) * 10000 & "," & a(7)
End SubPrivate Sub Command2_Click()
CommonDialog1.InitDir = "C:\Documents and Settings\Administrator\桌面"
CommonDialog1.Flags = cdlOFNExplorer Or cdlOFNAllowMultiselect
CommonDialog1.Filter = "文本文件|*.txt" '设置读取文件的格式
CommonDialog1.ShowOpen
If CommonDialog1.filename <> "" Then
Text1 = CommonDialog1.filename
End If
End Sub
Dim s As String
Dim ss() As String
Dim linecount As Long
Dim i As Long
Open filename For Input As #1
Do
Line Input #1, s
linecount = linecount + 1
If 3 = linecount Then
ss = Split(s, ",")
For i = 0 To UBound(ss) - 1
value(i + 1) = ss(i)
Next i
Close #1
Exit Sub
End If
Loop While Not EOF(1) '85127
Close #1
End Sub
Private Sub Command1_Click()
Dim a(1 To 100) As String
getvalue CommonDialog1.filename, a
Text2.Text = a(8) & "," & a(5) & "," & a(1) * 10000 & "," & a(2) * 10000 & "," & a(7)
End SubPrivate Sub Command2_Click()
CommonDialog1.InitDir = "C:\Documents and Settings\Administrator\桌面"
CommonDialog1.Flags = cdlOFNExplorer Or cdlOFNAllowMultiselect
CommonDialog1.Filter = "文本文件|*.txt" '设置读取文件的格式
CommonDialog1.ShowOpen
If CommonDialog1.filename <> "" Then
Text1 = CommonDialog1.filename
End If
End Sub
解决方案 »
- ado连接数据库怎么提示错误啊?请各位楼主帮帮我,谢谢!
- 请问像asp的global.asa那样的文件,vb中写在哪?
- 怎样在进入窗体时,自动变为全屏、最大化和最小化
- 有关程序打包的一个问题
- 怎么修改文件夹和文件的名字???
- VB中的简单组合问题
- 关于internet transfer control提交表单
- langzhi: 在VB中是不是自动加载资源。比如我的程序中有一PICTURE,在设计时已经指定了PICTURE属性,是不是程序就自己把图像文件包含到程序里却了呢?而不用另外发布图像文件了呢?
- 请问实现象oicq中的我的好友,陌生人那个上下滚动的那个玩意,用什么控件
- 如何用vb打开有已知密码的Word文档?
- 我想在File1中只显示指定文件名的TXT文件如何设置呢?
- 请问: excel vba, 打开多个xls文件, 搜索字符串,写入另一个sheet的问题
只有用jennyvenus 的了
要不我再发我的数据文件给你看一下吧 帮帮忙拉
解结了给你加分
数据如下
测站名,砧标高,后视点名,后视仪标高,后视左水平角,后视左垂直角,后视左斜距,后视右水平角,后视右垂直角,后视右斜距,前视点名,前视仪标高,前视左水平角,前视左垂直角,前视左斜距,前视右水平角,前视右垂直角,前视右斜距,方向角,方位角,边 长,X坐标(M),Y坐标(M)
1 ,村Ⅲ1, 1.507
0.0054,0.0254,-0.0668,0.0039,738.9338,0.0669,11044,Z1,209.2453,5
村IG15,1.485,V5187,1.290,135.2059,89.3954,175.377,315.2059,270.2039,175.377,5038,1.290,0.0000,90.0907,60.203,180.0004,269.5118,60.203,224.3903,254.0353,60.201,16941.210,50115.600 后面还有行多行
我只要第三行的就是上面这一行(0.0054,0.0254,-0.0668,0.0039,738.9338,0.0669,11044,Z1,209.2453,5)
上次jennyvenus的只能提取逗号前面的数据即(……209.2453,5),后面的,5就提取不出来,你顺便再改一下把最后面的(,5)也提取出来即(Z1,0.0054,0.0254,738.9338,11044,5) thank you
上面的代码:commondialog允许多选,但getvalue并没有处理多选这种情况,也就是说,一次只能处理一个文件,要想批量处理,需要修改代码!
实现上,我在你哪个贴子里说的很清楚!我不想多说了!像这种"用户定义类型未定义 "错误,只是没有引用 或没有放控件所造成的!你看看:http://topic.csdn.net/u/20080408/20/79d91b2e-c7c5-4305-b61f-e5d728eb7f56.html
11楼的
应该是
For i = 0 To UBound(ss)
但是还是希望jennyvenus 能帮我改一下
我想知道是怎么写的
在此非常感谢两位对我的指点,过两天结时再给两位加分.
'原来顺序是8,5,1,2,7,现在顺序是8,1,2,5,7,10,并且1,2没有乘1000。
Private Sub getvalue(ByVal filename As String, ByRef value() As String)
Dim s As String
Dim ss() As String
Dim linecount As Long
Dim i As Long
Open filename For Input As #1
Do
Line Input #1, s
linecount = linecount + 1
If 3 = linecount Then
ss = Split(s, ",")
For i = 0 To UBound(ss) - 1
value(i + 1) = ss(i)
Next i
Close #1
Exit Sub
End If
Loop While Not EOF(1) '8,1,2,5,7,10
Close #1
End Sub
Private Sub Command1_Click()
Dim a(1 To 100) As String
getvalue CommonDialog1.filename, a
Text2.Text = a(8) & "," & a(1) & "," & a(2) & a(5) & "," & "," & a(7) & "," & a(10)
End Sub Private Sub Command2_Click()
CommonDialog1.InitDir = "C:\Documents and Settings\Administrator\桌面"
CommonDialog1.Flags = cdlOFNExplorer Or cdlOFNAllowMultiselect
CommonDialog1.Filter = "文本文件 ¦*.txt" '设置读取文件的格式
CommonDialog1.ShowOpen
If CommonDialog1.filename <> "" Then
Text1 = CommonDialog1.filename
End If
End Sub