Public Sub file_dat()
Dim datfile As Stream
Dim i As Integer
Dim k As Integer
Dim data As String
Dim lng As Variant
Dim alt As Variant
Dim bss As Variant
Dim dst As Variant
Dim snt As Variant
Dim buss As Variant
Dim cli As Variant
data = Format(Now, "mm dd yyyy ")
datfile = Open mydir & "/" & Label2.Text & ".dat" For Create
Write #datfile, label2.Text & Chr(13) & Chr(10)
Write #datfile, "SURVEY NAME: " & label2.Text & Chr(13) & Chr(10)
Write #datfile, "SURVEY DATE:" & Space$(12 - Len(data)) & data & "COMMENT:" & Chr(13) & Chr(10)
Write #datfile, "SURVEY TEAM: " & Chr(13) & Chr(10)
Write #datfile, "?" & Chr(13) & Chr(10)
Write #datfile, "DECLINATION: 0.00 FORMAT: DMMDUDRLADLN CORRECTIONS: 0.00 0.00 0.00" & Chr(13) & Chr(10)
Write #datfile, Chr(13) & Chr(10)
Write #datfile, " FROM" & " TO" & " LENGTH" & " BEARING" & " INC" & " LEFT" & " UP" & " DOWN" & " RIGHT" & " FLAGS" & " COMMENTS" & Chr(13) & Chr(10)
Write #datfile, Chr(13) & Chr(10)
For i = 0 To GridView3.Rows.Count - 1
k = i
lng = Replace$(Format(Val(GridView3[k, 2].Text) / 0.3048, "0.00"), ",", ".")
buss = Replace$(Format(Val(GridView3[k, 3].Text), "0.00"), ",", ".")
cli = Replace$(Format(Val(GridView3[k, 4].Text), "0.00"), ",", ".")
alt = Replace$(Format(Val(GridView3[k, 5].Text) / 0.3048, "0.00"), ",", ".")
bss = Replace$(Format(Val(GridView3[k, 6].Text) / 0.3048, "0.00"), ",", ".")
dst = Replace$(Format(Val(GridView3[k, 7].Text) / 0.3048, "0.00"), ",", ".")
snt = Replace$(Format(Val(GridView3[k, 8].Text) / 0.3048, "0.00"), ",", ".")
Write #datfile, Space$(12 - Len(GridView3[k, 0].Text)) & GridView3[k, 0].Text & Space$(13 - Len(GridView3[k, 1].Text)) & GridView3[k, 1].Text & Space$(9 - Len(lng)) & lng & Space$(9 - Len(buss)) & buss & Space$(9 - Len(cli)) & cli & Space$(9 - Len(snt)) & snt & Space$(9 - Len(alt)) & alt & Space$(9 - Len(bss)) & bss & Space$(9 - Len(dst)) & dst & Chr(13) & Chr(10)
Next
Close #datfile
Message.Info("file cretato")
End