kwhw.net
相关文档
当前位置:首页 >> vBA 读取txt文件 >>

vBA 读取txt文件

Private Sub Command1_Click() Dim txt As String Open "C:\AAA.TXT" For Input As #1 Do While Not EOF(1) Line Input #1, txt MsgBox txt Loop Close #1 End Sub

dim i as,s() interage Open "你的文件路径" For Input As #1 Do Until EOF(1) s(i++)=Input #1,name,id,score '姓名,学号,成绩 Loop for k=0 to i print s(i) ok

Private Sub CommandButton1_Click()Dim filename, inputstring As StringDim i As IntegerDim datai = 1filename = "d:\WYKS.txt" '本列TXT文件放在D盘中Open filename For Input Access Read As #1Do While Not EOF(1)Line Input #1, inputstr...

既然知道指定字符,何不直接输进去?

可以使用如下的代码,复制如下代码到VBA模块中运行即可。 如下代码代表4行4列,如果其余行或列数则可更改相应的数字。 具体步骤如下: 打开office excel; Alt+F11打开VBA编辑器; 复制如下代码到模块中; F5运行该模块; 按照提示进行如下步骤...

1、模块中写下面代码 Sub otime() Application.OnTime Now() + TimeValue("00:00:02"), "duqu" End Sub Sub duqu() '读取txt的代码 Call otime End Sub 2、在workbook的open事件中写如下代码 Private Sub Workbook_Open() Call otime End Sub

Sub s() Open ThisWorkbook.Path & "\a.txt" For Input As #1 k = 9 Do While Not EOF(1) Line Input #1, a a = Application.Trim(Replace(a, "--", " ")) Cells(k, 2).Resize(1, 3) = Split(a) k = k + 1 Loop Close #1End Sub

Sub test() Dim starRng As Range Set starRng = Sheet1.Range("B5") '要输入的第一个单元格 Dim txtPath As String, nextLine As String txtPath = ThisWorkbook.Path & "\temp.txt" 'txt所在的目录 Open txtPath For Input As #1 Do While Not...

1、直接采用Open函数+Line input命令Private Sub txt_read() Dim txt As String Open "D:\dzh.txt" For Input As #1 ' '对文件做任何 I/O 操作之前都必须先打开文件。Open 语句分配一个缓冲区供文件进行 I/O 之用, '并决定缓冲区所使用的访问方...

网站首页 | 网站地图
All rights reserved Powered by www.kwhw.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com