9Mcode comment |
 |
 |
|
|
|
 |
- - - - - - - - - - - - - - ผู้ให้การสนับสนุน- - - - - - - - - - - - - -
|
|
 |
กระทู้ #2005 [Vb] (จาก IP: 125.24.201.74)
ดึงข้อมูลจาก text file มาคำนวณ ทำยังงัยค่ะ
มี text file ชื่อ elec.txt ซึ่งเก็บค่าเป็นตัวเลขมีจุดทศนิยม 2 ตำแหน่ง เรียงกันจากบนลงล่างค่ะ อยากทราบวิธีการดึงมาทีละค่าเเล้วนำมาคำนวณทำอย่างไรค่ะ แล้วถ้าต้องการให้ผลลัพธ์เก็บลง text file อีกต้องทำอย่างไรค่ะ
|
จากคุณ
:
yamiily / tnmslp@yahoo.com [2008-05-11 00:33:05]
|
|
ความคิดเห็น #26744 (จาก IP: 58.8.184.121)
คุณก็ read มาทีละ line มาเป็น string แล้วเอาค่ามาเป็นเป็น Double โดยใช้ function CDbl เก็บใน array หรือจะคำนวนเลย ตามต้องการ
-------------------------- '(general declaration)
Dim nFileNum As Integer, sText As String, sNextLine As String, lLineCount As Long
'==================================
Private Sub Command1_Click()
' Get a free file number nFileNum = FreeFile
' Open a text file for input. inputbox returns the path to read the file Open "C:\Documents and Settings\Sudeep\My Documents\3.txt" For Input As nFileNum lLineCount = 1 ' Read the contents of the file Do While Not EOF(nFileNum) Line Input #nFileNum, sNextLine 'do something with it 'add line numbers to it, in this case! sNextLine = sNextLine & vbCrLf sText = sText & sNextLine
Loop Text1.Text = sText
' Close the file Close nFileNum
End Sub
|
จากคุณ
:
sup98 [2008-05-11 10:50:10]
|
 |
|
- - - - - - - - - - - - - - ผู้ให้การสนับสนุน- - - - - - - - - - - - - -
|
|
|
|
|
|
|