读.txt文件

CommonDialog1.CancelError = True
On Error GoTo errhandler
Dim res As String
Dim Str1 As String
Str1 = App.Path & "/save" & "/振值/" & Date
res = Dir(Str1, vbDirectory) '判断有没有"str1"文件
If res = "" Then   '没有该文件
MakeSureDirectoryPathExists Str1 & "/"    '创建(api)
End If
CommonDialog1.InitDir = Str1
CommonDialog1.FileName = "振值.txt"
CommonDialog1.Filter = "(*.txt)|*.txt"   可打开文件类型
CommonDialog1.ShowOpen
If CommonDialog1.FilterIndex = 1 Then
If CommonDialog1.FileName <> "" Then
Dim s1 As String
Open CommonDialog1.FileName For Input As #1   '以读文件的方式打开;output:print以写的方式打开

Open App.Path & "/filename.set" For Binary As #Free_Num   'Binary 读二进制文件 get #1,,s1

i = 0
Do While Not EOF(1)   '如果没到文件末尾则循环按行读取
's1 = Input(100, #1)
line Input #1, s1    '按行读取
If s1 <> "" Then
    str = Split(s1, " ")    '以空格为分界符,把str分解为数则形式 
    Num = UBound(str)       '最大下标
    If i = 0 Then
        ReDim Strvalue(3, Num)
        ReDim ArrayDate(Num)
        For j = 0 To UBound(str)
            ArrayDate(j) = str(j)
        Next j
    Else
        For j = 0 To UBound(str)
            Strvalue(i - 1, j) = str(j)
        Next j
    End If
End If
i = i + 1
If s1 = "" Then
    i = i - 1
End If
Loop
Close #1

 

ReDim MaxStrvalue(3) As Single
For i = 0 To 3
    If Strvalue(i, 0) <> "" Then
        For j = 1 To UBound(str)
            If Strvalue(i, j) > MaxStrvalue(i) Then
                MaxStrvalue(i) = Strvalue(i, j)
            End If
        Next j
    End If
Next i
End If

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值