爱问知识人 爱问教育 医院库

怎么读取文本文件?急急急

首页

怎么读取文本文件?急急急

怎么从c:\123.txt读取一行数据,每个数据之间用
“,“隔开 ,读取后第一行数据为阿a(0,0),a(0,1)......第二行为a(1,0),a(1,1)....

提交回答
好评回答
  • 2019-03-08 16:18:04
      一下代码可以读出 这个文本文档有多行,每行多少列!和内容,要把内容放数组,只要再做循环就可以了!
    Dim i%, k As Integer, t(), a()
    Private Sub Command1_Click()
    Text1。Text = ""
    Dim inputdata
    Open "c:3。
      txt" For Input As #1 Do While Not EOF(1) Line Input #1, inputdata i = i + 1 ReDim t(i) t(i) = Len(inputdata) '算出每行多少字符,就是多少列 ReDim a(i, t(i)) a(i, t(i)) = inputdata '为了能把每个对应这里把每行的数据记录 Picture1。
      Print i; t(i); "("; a(i, t(i)); ")" Text1。Text = Text1。Text + inputdata + vbCrLf Loop Close #1 End Sub 。

    梁***

    2019-03-08 16:18:04

其他答案

    2019-03-08 16:52:54
  •   因为不知道 123。txt 的内容, 也就不知道你的对不对?
    请把123。txt和程序告诉我。这个问题不难解决。
    程序for string data: Please tell me is this right for you。
    假设 123。
      txt是这样: asdf,erty,wefv,tgbhh,。。。h deep,cat,red,。。。yellow 。。。。。 。。。。。 Please let me know, what do you think about your program。
       Thhis program can read any line and one line have any number of data。 Now you have two programs。 One is for string and attachment for interger。
       Private Sub Command1_Click() Dim i, j, p, pf As Integer Dim str As String Dim cell(0 To 80, 0 To 80) As String p = 1 i = 0 j = 0 Open "c:\123。
      txt" For Input As #1 Do Until EOF(1) = True Line Input #1, str pf = InStr(p, str, ",") Do While (pf <> 0) cell(i, j) = Mid(str, p, pf - p) p = pf + 1 j = j + 1 pf = InStr(p, str, ",") If pf = 0 Then cell(i, j) = Mid(str, p, Len(str)) End If Loop i = i + 1 j = 0 p = 1 Loop Close #1 For i = 0 To 2 For j = 0 To 9 Text2 = Text2 & cell(i, j) & " " Next Next End Sub attachment for interger data。
      

    z***

    2019-03-08 16:52:54

  • 2019-03-08 16:34:10
  • int i,j;
    ifstream input_file;
    ofstream output_file;
    fstream io_file;
    input_file.open("c:\123.txt");
    for(j=0;j>a(i,j);}

    J***

    2019-03-08 16:34:10

类似问题

换一换
  • VB 相关知识

  • 电脑网络技术
  • 电脑网络

相关推荐

正在加载...
最新资料 推荐信息 热门专题 热点推荐
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 175-194
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):