Проверьте на ошибку программный код пож - VB
Формулировка задачи:
вместо
что нужно написать чтоб добавить последнюю строку, после строки содержащей максимальный элемент
Решение задачи: «Проверьте на ошибку программный код пож»
textual
Листинг программы
Function SetColsRows() Dim File As Long Dim N, i, M As Integer Dim LineTextFile As String N = 0 File = FreeFile Open App.Path & "\matrix.txt" For Input As #File Do Until EOF(File) Line Input #File, LineTextFile N = N + 1 Loop MSFlexGrid1.Rows = N Close #File i = 1 M = 0 Do While i <= Len(LineTextFile) If Mid(LineTextFile, i, 1) <> " " Then M = M + 1 i = i + 1 If i <= Len(LineTextFile) Then Do While Mid(LineTextFile, i, 1) <> " " i = i + 1 If i > Len(LineTextFile) Then Exit Do End If Loop End If Else i = i + 1 End If Loop MSFlexGrid1.Cols = M End Function Private Sub Command1_Click() SetColsRows Dim F As Long Dim MyText, Val As String Dim N, M, i As Integer N = -1 F = FreeFile Open App.Path & "\matrix.txt" For Input As #F Do Until EOF(F) Line Input #F, MyText N = N + 1 M = -1 i = 1 Do While i <= Len(MyText) If Mid(MyText, i, 1) <> " " Then M = M + 1 Val = Mid(MyText, i, 1) i = i + 1 If i <= Len(MyText) Then Do While Mid(MyText, i, 1) <> " " Val = Val + Mid(MyText, i, 1) i = i + 1 If i > Len(MyText) Then Exit Do End If Loop End If MSFlexGrid1.TextMatrix(N, M) = Val Else i = i + 1 End If Loop Loop Close #F End Sub Private Sub Command2_Click() Dim max, i, j As Integer max = Abs(Val(MSFlexGrid1.TextMatrix(0, 0))) For i = 0 To MSFlexGrid1.Rows - 1 For j = 0 To MSFlexGrid1.Cols - 1 If Abs(Val(MSFlexGrid1.TextMatrix(i, j))) > max Then max = Abs(Val(MSFlexGrid1.TextMatrix(i, j))) End If Next j Next i For i = 0 To MSFlexGrid1.Rows - 1 For j = 0 To MSFlexGrid1.Cols - 1 If Val(MSFlexGrid1.TextMatrix(i, j)) = 0 Then MSFlexGrid1.TextMatrix(i, j) = max End If Next j Next i End Sub Private Sub Command3_Click() max = Abs(Val(MSFlexGrid1.TextMatrix(0, 0))) For i = 0 To MSFlexGrid1.Rows - 1 k = 0 For j = 0 To MSFlexGrid1.Cols - 1 If Abs(Val(MSFlexGrid1.TextMatrix(i, j))) > max Then max = Abs(Val(MSFlexGrid1.TextMatrix(i, j))) End If Next j Next i i_1 = 0 MSFlexGrid2.Rows = MSFlexGrid1.Rows MSFlexGrid2.Cols = MSFlexGrid1.Cols For i = 0 To MSFlexGrid1.Rows - 1 k = 0 For j = 0 To MSFlexGrid1.Cols - 1 MSFlexGrid2.TextMatrix(i_1, j) = Val(MSFlexGrid1.TextMatrix(i, j)) If Val(MSFlexGrid2.TextMatrix(i_1, j)) = max Then k = k + 1 End If Next j If k <> 0 Then i_1 = i_1 + 1 MSFlexGrid2.AddItem (kol + 1) 'Г*îìåðГ* ñòðîê Гў ГІГ*áëèöå В№1 Гў êîòîðûõ ГҐГ±ГІГј Г¬Г*ГЄГ±ГЁГ¬Г*ëüГ*ûå ýëåìåГ*ГІГ» For j = 0 To MSFlexGrid1.Cols - 1 MSFlexGrid2.TextMatrix(i_1, j) = Val(MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, j)) Next j End If i_1 = i_1 + 1 kol = kol + 1 Next i End Sub Private Sub Command4_Click() Dim i, j As Integer For i = 0 To MSFlexGrid1.Rows - 1 For j = 0 To MSFlexGrid1.Cols - 1 If Val(MSFlexGrid1.TextMatrix(i, j)) = 0 Then MSFlexGrid1.RemoveItem (MSFlexGrid1.Row - (MSFlexGrid1.TextMatrix(i, j))) End If Next j Next i End Sub
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д