VB怎樣讀取指定的文字並顯示

2021-03-10 14:49:10 字數 939 閱讀 8393

1樓:橡皮樹的部落格

dim tmptxt as string ,tmpstr() as string

dim i as integer

open "d:\1.txt" for input as #1

tmptxt=strconv(inputb(lof(1),#1),vbunicode)

close #1

tmpstr=split(tmptxt,vbcrlf)

for i=0 to ubound(tmpstr)

text1=text1 & split(tmpstr(i),"-")(0) & vbcrlf

text2=text2 & split(tmpstr(i),"-")(1) & vbcrlf

text3=text3 & split(tmpstr(i),"-")(2) & vbcrlf

next i

2樓:匿名使用者

'樓上copy

的**,當檔案最後有空行時會下標越界。

dim lines as string

dim nextline as stringdim i as integer

open "d:\1.txt" for input as #1do while not eof(1)

line input #1, nextli***ext1 = text1 & mid(nextline, 1, 11) & vbcrlf

text2 = text2 & mid(nextline, 13, 8) & vbcrlf

text3 = text3 & mid(nextline, 22, 2) & vbcrlf

loop

close #1

3樓:匿名使用者

這個可以把一行讀出來,然後按「-」分割成三部分,最後把每一行的各個部分連起來

VB讀取,並將指定字串替換,VB讀取TXT,並將TXT指定字串替換

檢索 然後判斷左邊或右邊是否是你需要替換的字串,如果是,則替換掉 讀一行替換一行 寫入新檔案。不會vb學呀,三天搞定,聰明點的一天。用readline 讀取txt的每一行,然後用 replace 逐行替換。vb 替換txt文字檔案中的指定字串 5 vb如何讀取txt檔案中指定某行的內容到變數中 vb...

VB如何連續讀取串列埠資料,vb怎樣讀取串列埠資料並進行處理?

vb6.0mscomm控制元件可以利用oncomm事件連續獲取來自外設傳送的訊號。基於 1 mscomm控制元件的rthreshold 屬性不為0和恰當的接收 2 使用電腦主機板物理com口或pci多串列埠卡上的com口com,這樣的com口是全雙工的,傳送與接收不會衝突。3 高質量的接收 和符合通...

如何用python讀取文字中指定行的內容

readsomelines.py usr bin env python3 import sys fname aa.txt def main lines i for i in sys.argv 1 if i.isdigit with open fname as f s f.read split n p...