Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

vb的麻煩....><

0 views
Skip to first unread message

怒火戰區

unread,
May 14, 1999, 3:00:00 AM5/14/99
to

以下是我嘗試用vb做讀,寫某個檔案的動作,
讀檔來源為TEXT1.TEXT裏的檔,寫的目的檔則是text2.text裏的檔.
可是卻在執行到行號為90時,出現"檔案己開啟"的錯誤訊息,請問,為
什麼會這樣呢..(行號只是為了方便看,真正寫程式時當然沒有打上去)


10 Option Explicit
20 Private Sub Form_click()
30 Dim nfile As Integer
40 Dim ni, tempchr As Integer
50 nfile = FreeFile
60 Open Text1.Text For Input As #1
70 ReDim pj(1 to lof(1)) As Byte
80 get #1, , pj()
90 Open Text2.Text For Output As #nfile
100 For ni = LBound(pj) To UBound(pj)
110 tempchr = (pj(ni) ^ 3 Mod 255)
120 Next ni
130 Print #nfile, Chr(tempchr)
140 Close #nfile
150 Close #1
160 End Sub

--
--
[m● Origin : 雲林科技大學藍天使 <bbs.yuntech.edu.tw> [FROM: 140.125.200.109]

怒火戰區

unread,
May 14, 1999, 3:00:00 AM5/14/99
to
==> 在 lcs@YUNTECH (怒火戰區) 的文章中提到:
: 以下是我嘗試用vb做讀,寫某個檔案的動作,

: 讀檔來源為TEXT1.TEXT裏的檔,寫的目的檔則是text2.text裏的檔.
: 可是卻在執行到行號為90時,出現"檔案己開啟"的錯誤訊息,請問,為
: 什麼會這樣呢..(行號只是為了方便看,真正寫程式時當然沒有打上去)
: 10 Option Explicit
: 20 Private Sub Form_click()
: 30 Dim nfile As Integer
: 40 Dim ni, tempchr As Integer
: 50 nfile = FreeFile
: 60 Open Text1.Text For Input As #1
: 70 ReDim pj(1 to lof(1)) As Byte
: 80 get #1, , pj()
: 90 Open Text2.Text For Output As #nfile
: 100 For ni = LBound(pj) To UBound(pj)
: 110 tempchr = (pj(ni) ^ 3 Mod 255)
: 120 Next ni
: 130 Print #nfile, Chr(tempchr)
: 140 Close #nfile
: 150 Close #1
: 160 End Sub

抱歉...第60行的型態我是打binary而不是input

不想和世界說話

unread,
May 14, 1999, 3:00:00 AM5/14/99
to
※ 引述《lcs...@bbs.yuntech.edu.tw (怒火戰區)》之銘言:
: ==> 在 lcs@YUNTECH (怒火戰區) 的文章中提到:

: : 以下是我嘗試用vb做讀,寫某個檔案的動作,
: : 讀檔來源為TEXT1.TEXT裏的檔,寫的目的檔則是text2.text裏的檔.
: : 可是卻在執行到行號為90時,出現"檔案己開啟"的錯誤訊息,請問,為
: : 什麼會這樣呢..(行號只是為了方便看,真正寫程式時當然沒有打上去)
: : 10 Option Explicit
: : 20 Private Sub Form_click()
: : 30 Dim nfile As Integer
: : 40 Dim ni, tempchr As Integer
: : 50 nfile = FreeFile
: : 60 Open Text1.Text For Input As #1
: : 70 ReDim pj(1 to lof(1)) As Byte
: : 80 get #1, , pj()
: : 90 Open Text2.Text For Output As #nfile
: : 100 For ni = LBound(pj) To UBound(pj)
: : 110 tempchr = (pj(ni) ^ 3 Mod 255)
: : 120 Next ni
: : 130 Print #nfile, Chr(tempchr)
: : 140 Close #nfile
: : 150 Close #1
: : 160 End Sub
: 抱歉...第60行的型態我是打binary而不是input

我以前也有遇到這個問題...
你把30、50給砍掉
90、130、140的 #nfile 改成 #2
這樣應該就可以了....

要不然你可以試試看....
把150行給提到前面....
例如提到90行之前....

不過第二種方法我沒試過....

你自己看著辦吧....
--
※ Origin: 奇摩 大摩域 (bbs.kimo.com.tw) ◆ From: sh37-64.dialup.seed.net.tw

0 new messages