前两天写的面试用的,run macro-> select file->processingPublic BoolOpenSuccess As Boolean
Private Sub start_Click()
Dim Value As String
Call OpenFile(StrFileName, BoolOpenSuccess)
Application.ScreenUpdating = False
If BoolOpenSuccess = False Then
Exit Sub
End If
'open file for input
Open StrFileName For Input As #5
Do While Not EOF(5)
On Error Resume Next
Line Input #5, strLine
'Get stepsize info
If BoolGetWidth = False Then
If InStr(1, strLine, "Pulse width:") > 0 Then
BoolGetWidth = True
If InStr(1, strLine, "ns") > 0 Then
'Pulse width
'Format: Pulse width:100ns
pos1 = InStr(1, strLine, ":")
pos2 = InStr(pos1, strLine, "s")
Value = Mid(strLine, pos1 + 1, pos2)
'store value in sheet
Worksheets("Result").Range("C10") = Value
Exit (more...)
如果你的file1位置固定,可以用以下的code
'get product and tech from user input
Location = Worksheets("control").Range("B34")
PartID = Worksheets("control").Range("G9")
Dim FilePath As String
FilePath = Location & "\" & PartID & "\"
If BoolManualXML = False Then
StrFileName = FilePath & ArrFileName(1)
Else
Call OpenFile(StrFileName, BoolOpenSuccess)
Application.ScreenUpdating = False
If BoolOpenSuccess = False Then
Exit Sub
End If
End If
Location = Worksheets("control").Range("B34")
PartID = Worksheets("control").Range("G9")
Dim FilePath As String
FilePath = Location & "\" & PartID & "\"
If BoolManualXML = False Then
StrFileName = FilePath & ArrFileName(1)
Else
Call OpenFile(StrFileName, BoolOpenSuccess)
Application.ScreenUpdating = False
If BoolOpenSuccess = False Then
Exit Sub
End If
End If
工作了,很少去学校。我可以提供进货渠道及100多个客户号码给想在NUS卖卡的朋友