Dim fno As Integer = FreeFile() Dim filePath As String = $"C:\Users\mycomp\Desktop\{TextBox1.Text}.txt" FileOpen(fno, filePath, OpenMode.Output) PrintLine(fno, BNX + 1, BNZ + 1, DX, DZ) Dim X1 = Xmin For XX As Integer = 1 To BNX + 1 Dim Z1 = Zmin For I As Integer = 1 To BNZ + 1 PrintLine(fno, X1, Z1, MUD1(I), MUD2(I)) Z1 += DZ Next I X1 += DX Next XX FileClose(fno) fno = 0