土方计算辅助软件4surfer8.0
Private Sub CommandButton1_Click()
Dim startx, starty As Integer
Dim maxx, maxy As Integer
Dim i, j As Integer
'Dim FileNum, Mode, Handle
Dim filename As String
startx = 5
starty = 4
maxx = 200
maxy = 20
With Application.FileDialog(msoFileDialogSaveAs)
.AllowMultiSelect = False
.Show
filename = .SelectedItems(1)
End With
FileNum = 1 ' 指定文件号。
Open filename For Append As #1 ' 打开文件。
For i = 0 To maxx
If Cells(startx + i, 1).Value <> "" Then
For j = 0 To maxy
If Cells(startx + i, starty + j * 2).Value <> "" And Cells(startx + i, starty + j * 2 + 1).Value <> "" Then
If Cells(3, starty + j * 2).Value <> "" Then
If Cells(3, starty + j * 2).Value = "外边" Then
Print #1, Cells(startx + i, 1).Value, Cells(startx + i, starty + j * 2 + 2).Value, Cells(startx + i, starty + j * 2 + 1).Value
Exit For
Else
Print #1, Cells(startx + i, 1).Value, Cells(3, starty + j * 2).Value, Cells(startx + i, starty + j * 2 + 1).Value
End If
Else
Exit For
End If
End If
Next j
Else
Exit For
End If
Next i
Close FileNum ' 关闭文件。
End Sub