Private Sub Button1_Click(sender As Object, e As EventArgs, Label2 As Object, ListBox1 As Object) Handles Button1.Click Label2.Text = ListBox1.Items(ListBox1.SelectedIndex) End Sub Private Sub Button2_Click(sender As Object, e As EventArgs, Label2 As Object, TextBox2 As Object, TextBox3 As Object, TextBox4 As Object, TextBox5 As Object, TextBox6 As Object, TextBox7 As Object, TextBox1 As Object) Handles Button2.Click 'Dim X(20000000) As Single, Y(20000000) As Single, UD1(20000000) As Single, UD2(20000000) As Single Dim MUD1(1000) As Single, MUD2(1000) As Single Dim DT As Integer Dim Xmax As Single, Xmin As Single Dim Zmax As Single, Zmin As Single Dim TotalX As Single, TotalZ As Single Dim X1 As Single, I As Integer, BNX As Integer, BNZ As Integer, Z1 As Single Dim Dx As Single, Dz As Single Dim UD1SUM As Single, UD2SUM As Single, CT As Integer, XX As Integer Dim fileReader As String fileReader = My.Computer.FileSystem.ReadAllText(Label2.Text) Dim fileName As String = Label2.Text ' = "C:\test\example.txt" Dim enc = System.Text.Encoding.GetEncoding("Shift_JIS") Dim lines As String() = System.IO.File.ReadAllLines(fileName, enc) Dim upperIndex As Integer = lines.GetUpperBound(0) Dim X(upperIndex), Y(upperIndex), UD1(upperIndex), UD2(upperIndex) As Single Dim splitter As Char() = {ControlChars.Tab, " "c, " "c} Dim separator = StringSplitOptions.RemoveEmptyEntries For rowIndex = 0 To upperIndex Dim columns As String() = lines(rowIndex).Split(splitter, separator) Single.TryParse(columns(0), X(rowIndex)) Single.TryParse(columns(1), Y(rowIndex)) Single.TryParse(columns(2), UD1(rowIndex)) Single.TryParse(columns(3), UD2(rowIndex)) Next rowIndex '解析対象区域設定 Xmin = TextBox2.Text Xmax = TextBox3.Text Zmin = TextBox4.Text Zmax = TextBox5.Text TotalX = Xmax - Xmin TotalZ = Zmax - Zmin Dim fno As Integer = FreeFile() Dim filePath As String = $"C:\Users\mycomp\Desktop\{TextBox1.Text}.txt" FileOpen(fno, filePath, OpenMode.Output) '速度変動のRMS値の計算 BNX = TextBox6.Text BNZ = TextBox7.Text Dx = TotalX / BNX Dz = TotalZ / BNZ PrintLine(fno, BNX + 1, BNZ + 1, Dx, Dz) X1 = Xmin For XX = 1 To BNX + 1 Z1 = Zmin For I = 1 To BNZ + 1 UD1SUM = 0 UD2SUM = 0 CT = 0 For J = 1 To DT If X1 - Dx / 2 < X(J) And X(J) < X1 + Dx / 2 Then If Z1 - Dz / 2 < Y(J) And Y(J) < Z1 + Dz / 2 Then CT = CT + 1 UD1SUM = UD1SUM + UD1(J) UD2SUM = UD2SUM + UD2(J) End If End If Next J If CT <> 0 Then MUD1(I) = UD1SUM / CT MUD2(I) = UD2SUM / CT End If PrintLine(fno, X1, Z1, MUD1(I), MUD2(I)) Z1 = Z1 + Dz Next I X1 = X1 + Dx Next XX FileClose(fno) fno = 0 End Sub