กระทู้เก่าบอร์ด อ.สุภาพ ไชยา
        
           471   6		  
          
					  
		    URL.หัวข้อ / 
		    URL
        
        เรียนถามอาจารย์สุภาพ เรื่องการ Write Text File      
		
    
      ผมเห็นคำสั่งนี้ใน VB สามารถ Write "H" ที่เหนือข้อมูลซึ่งเป็น Text File ได้ไม่ทราบว่า Access 2000 ต้องใช้คำสั่งอย่างไรครับ 
 
 
คำสั่งของ VB
Open "c:\apps_pub\table1.txt" For Input As #1
Print #1, "H"
Close #1
 
ข้อมูล
็H
0001
0002
0003
0004
    
    
  คำสั่งของ VB
Open "c:\apps_pub\table1.txt" For Input As #1
Print #1, "H"
Close #1
ข้อมูล
็H
0001
0002
0003
0004
				6 Reply in this Topic. Dispaly 1  pages and you are on page number 1 
				
        
    1 @R03486    
        
  
      ก็ใช้คำสั่งเดียวกันได้เลยครับ 
    
  
        
    2 @R03487    
        
  
      ผมลองดูแล้ว ขึ้น Bad file mode  ช่วยอธิบายด้วยครับ    
    
  
        
    3 @R03488    
        
  
      ขออภัยครับ  
ต้องเปลี่ยน Input เป็น Output แทน
    
  ต้องเปลี่ยน Input เป็น Output แทน
        
    4 @R03496    
        
  
      ได้แล้วครับ ขอบคุณครับ    
    
  
        
    5 @R03499    
        
  
      ผมขอเรียนถามอาจารย์เพิ่มเติมอีกครับ  แล้วเมื่อเรา Output ทับไฟล์ไปแล้ว Data ที่เราต้องนำมาลงต่อจาก Header จะต้องทำอย่างไรครับ โดยที่ไม่ต้องนำมาเก็บไว้ที่ Table ก่อน เพื่อสุดท้ายผมจำเป็นต้องสรุปด้วยว่า มีจำนวนเท่าไหร่ครับ ตัวอย่างที่สำเร็จรูปของผมก็คือ 
H
0001
0002
0003
0004
Total = 4 Records
    
    
  H
0001
0002
0003
0004
Total = 4 Records
        
    6 @R03505    
        
    
      ผมทดสอบได้ Code ดังนี้ครับ 
Private Sub Command0_Click()
Dim x As String
Dim y As String
Dim Datavar As String
x = "c:\apps_pub\table1.txt"
y = "c:\apps_pub\table11.txt"
Open x For Output As #1
Open y For Input As #2
xstatus = y
Print #1, "H" & " " & "00000" & " " & Date
Do While Not EOF(2)
Dim i
'For i = 1 To 20
Line Input #2, Datavar
Print #1, Datavar
'Exit Do
Loop
'Next i
Close #1
Close #2
End Sub
    
  Private Sub Command0_Click()
Dim x As String
Dim y As String
Dim Datavar As String
x = "c:\apps_pub\table1.txt"
y = "c:\apps_pub\table11.txt"
Open x For Output As #1
Open y For Input As #2
xstatus = y
Print #1, "H" & " " & "00000" & " " & Date
Do While Not EOF(2)
Dim i
'For i = 1 To 20
Line Input #2, Datavar
Print #1, Datavar
'Exit Do
Loop
'Next i
Close #1
Close #2
End Sub
      Time: 0.2171s
    
      
		