Re: ทำ vba ไว้ที่เครื่องตัวเองเปิดได้แต่ไปเปิดกับเครื่องอื่น
Posted: Thu Feb 28, 2013 9:13 pm
Code: Select all
Private Sub CmdConvrt_Click()
Dim Handle As Integer, File_Name As String
Dim WriteRow As Long, TemArr, OneLine As String
Dim Price1, Price2, Price3 As String
Dim Pono() As Variant
Dim Invno() As String
Dim Chkval As Integer
Dim Sump1 As Integer
Dim Sump2 As Integer
Dim Sump3 As Integer
Dim Sumpr As Integer
Dim Sumprice As Integer
Handle = FreeFile
File_Name = "D:\testrun.txt"
Open File_Name For Input As #Handle
Do While Not EOF(Handle)
Line Input #Handle, OneLine
TemArr = Split(OneLine, "|")
If UBound(TemArr) > 1 Then
WriteRow = WriteRow + 1
Cells(WriteRow, 1) = "VMI050"
Cells(WriteRow, 2) = TemArr(1)
Cells(WriteRow, 3) = TemArr(2)
'Pono = TemArr(4)
Cells(WriteRow, 4) = TemArr(4)
Cells(WriteRow, 5) = TemArr(5)
Cells(WriteRow, 6) = TemArr(5)
Cells(WriteRow, 7) = TemArr(7)
Cells(WriteRow, 8) = TemArr(8)
Cells(WriteRow, 9) = " PC"
If TemArr(4) = 9999999999# Then
Cells(WriteRow, 9) = " "
Cells(WriteRow, 11).Value = Application.Sum( _
Range("K1:K" & WriteRow))
End If
If TemArr(29) = "S225-1-1011-001" Then
Cells(WriteRow, 10) = Txtprc1.Value
Cells(WriteRow, 11) = TemArr(8) * Txtprc1
Sump1 = Cells(WriteRow, 11)
ElseIf TemArr(29) = "S225-1-1211-002" Then
Cells(WriteRow, 10) = Txtprc2.Value
Cells(WriteRow, 11) = TemArr(8) * Txtprc2
Sump2 = Cells(WriteRow, 11)
ElseIf TemArr(29) = "S225-1-DUMM-001" Then
Cells(WriteRow, 10) = Txtprc3.Value
Cells(WriteRow, 11) = TemArr(8) * Txtprc3
Sump3 = Cells(WriteRow, 11)
End If
'Cells(WriteRow, 11) = TemArr(8) * DC
Cells(WriteRow, 12) = TemArr(9)
Cells(WriteRow, 13) = TemArr(24)
Cells(WriteRow, 14) = TemArr(25)
Cells(WriteRow, 15) = TemArr(26)
Sumpr = Sump1 + Sump2 + Sump3
'Sumprice = Sumpr + Sumprice
'Sumprice = Sumprice + Sumpr
End If
'Sumprice = Sumprice + Sumpr
Loop
Close #Handle
End Sub