Option Explicit Private Const Limit As Integer = 15000 '検証データの件数 Private Sub Form_Load() Command1.Caption = "単純連結法" Command2.Caption = "部分連結法" Command3.Caption = "Midステートメント法" Command4.Caption = "グリッドクリア" MSHFlexGrid1.FixedCols = 0 MSHFlexGrid1.FixedRows = 1 MSHFlexGrid1.Cols = 1 MSHFlexGrid1.Rows = Limit + 1 End Sub Private Sub Command4_Click() MSHFlexGrid1.Clear End Sub Private Sub Command1_Click() Dim t As Single '経過時間測定用 t = Timer Dim n As Integer 'ループカウンタ Dim s As String '連結結果 For n = 1 To Limit s = s & CStr(n) & "行目" & vbCrLf Next 'Debug.Print s SetData s Debug.Print FormatNumber(Timer - t, 4) & "秒 - "; Command1.Caption MsgBox FormatNumber(Timer - t, 4) & "秒", vbInformation, Command1.Caption End Sub Private Sub Command2_Click() Dim t As Single '経過時間測定用 t = Timer Dim n As Integer 'ループカウンタ Dim s As String '連結結果 s = "" For n = 1 To Limit s = s & (CStr(n) & "行目" & vbCrLf) Next 'Debug.Print s SetData s Debug.Print FormatNumber(Timer - t, 4) & "秒 - " & Command2.Caption MsgBox FormatNumber(Timer - t, 4) & "秒", vbInformation, Command2.Caption End Sub Private Sub Command3_Click() Dim t As Single '経過時間測定用 t = Timer Const BlockSize As Long = 100000 '一回あたりのメモリ確保サイズ Dim n As Integer 'ループカウンタ Dim s As String '連結結果 Dim p As Long '現在の文字数 Dim data As String '連結させる文字列 Dim l As Long '連結させる文字列の長さ s = "" p = 1 For n = 1 To Limit data = (CStr(n) & "行目" & vbCrLf) l = Len(data) Do Until p + l <= Len(s) s = s & Space(BlockSize) Loop Mid(s, p, l) = data p = p + l Next s = Left(s, p) SetData s Debug.Print FormatNumber(Timer - t, 4) & "秒 - "; Command3.Caption MsgBox FormatNumber(Timer - t, 4) & "秒", vbInformation, Command3.Caption End Sub Private Sub SetData(ByVal Text As String) 'Debug.Print Text MSHFlexGrid1.Col = 0 MSHFlexGrid1.Row = 1 MSHFlexGrid1.RowSel = Limit MSHFlexGrid1.Clip = Text MSHFlexGrid1.RowSel = 1 End Sub