Re: [VBA ] 請問輸出問題

看板Visual_Basic作者時間19年前 (2006/06/17 23:13), 編輯推噓2(201)
留言3則, 2人參與, 最新討論串2/2 (看更多)
※ 引述《silvaco ()》之銘言: : Dim FileNo As Integer : Dim CurrentLine As String : Dim Filename As String : Filename = "C:\Documents and Settings\data.txt" : ' Define file name : FileNo = FreeFile ' Establish free file handle : Open Filename For Output As #FileNo ' Open file (writing mode) : Print #FileNo, "This is a line of text" ' Save line : Print #FileNo, "This is another line of text" ' Save line : Close #FileNo ' Close file : 請問我要如何才能讓data可以變成是一個變數呢?? : 我想用now()函數把每天的檔案存進去~ : 請問可行嗎??該怎麼做呢?? : 請大家指導一下~~謝謝 剛才修改一下 Sub test() Dim data As Date Dim d, m, y As String Dim FileNo As Integer Dim CurrentLine As String Dim Filename As String Worksheets("sheet1").Range("a1").Value = Now() data = Worksheets("sheet1").Range("a1").Value d = Day(data) m = Month(data) y = Year(data) Filename = "C:\Documents and Settings\桌面\" & y & m & d & ".txt" ' Define file name FileNo = FreeFile ' Establish free file handle Open Filename For Output As #FileNo ' Open file (writing mode) Print #FileNo, "This is a line of text" ' Save line Print #FileNo, "This is another line of text" ' Save line Close #FileNo ' Close file End Sub 這樣月份存檔會變成只有一個位數 請問有什麼方法可以讓他有2位數嗎?? 例如6月是06而不是只有6 請大家指導一下~謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.135.251.190

06/17 23:24, , 1F
format(時間, "yyyymmdd") & .txt
06/17 23:24, 1F

06/17 23:30, , 2F
請問那個時間是必需指定的嗎??我怎麼直接填上去會錯誤呢??
06/17 23:30, 2F

06/17 23:42, , 3F
oh~ya~終於試出來了~~謝謝大家的指導:)
06/17 23:42, 3F
文章代碼(AID): #14b1mq0n (Visual_Basic)
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):
文章代碼(AID): #14b1mq0n (Visual_Basic)