VERSION 5.00 Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX" Begin VB.Form Form1 Caption = "Специально для Андрея" ClientHeight = 3195 ClientLeft = 60 ClientTop = 345 ClientWidth = 4680 Icon = "Tekst.frx":0000 LinkTopic = "Form1" ScaleHeight = 3195 ScaleWidth = 4680 StartUpPosition = 3 'Windows Default Begin MSComDlg.CommonDialog CommonDialog1 Left = 1440 Top = 2160 _ExtentX = 847 _ExtentY = 847 _Version = 393216 End Begin VB.TextBox Text2 Height = 765 Left = 1920 MultiLine = -1 'True ScrollBars = 3 'Both TabIndex = 6 Text = "Tekst.frx":0442 Top = 2280 Width = 2655 End Begin VB.CommandButton Command3 Caption = "Выход" Height = 375 Left = 3240 TabIndex = 5 Top = 0 Width = 1335 End Begin VB.CommandButton Command2 Caption = "Проверить" Enabled = 0 'False Height = 375 Left = 1680 TabIndex = 4 Top = 0 Width = 1455 End Begin VB.OptionButton Option2 Caption = "Произведение" Height = 255 Left = 240 TabIndex = 3 Top = 2640 Width = 1455 End Begin VB.OptionButton Option1 Caption = "Сумма" Height = 255 Left = 240 TabIndex = 2 Top = 2280 Value = -1 'True Width = 855 End Begin VB.TextBox Text1 Height = 1695 Left = 120 Locked = -1 'True MultiLine = -1 'True ScrollBars = 3 'Both TabIndex = 1 Text = "Tekst.frx":044B ToolTipText = "Текст из файла" Top = 480 Width = 4455 End Begin VB.CommandButton Command1 Caption = "Открыть" Height = 375 Left = 240 TabIndex = 0 Top = 0 Width = 1335 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Dim s As Integer, n As Integer, i As Integer Dim text As String ', Strfile As String, Fl As String Dim k() As String Dim fn As Integer Dim num As Integer, sum As Integer, pr As Integer Private Sub Command1_Click() fn = FreeFile On Error GoTo HandlerErr1 With CommonDialog1 .FileName = "*.txt" .Flags = cdlOFNHideReadOnly .ShowOpen End With File = CommonDialog1.FileName Open File For Input As fn Text1.text = Input(LOF(fn), fn) Close Command2.Enabled = True Exit Sub HandlerErr1: MsgBox "Ошибка" & Str$(Err.Number) & " при чтении." & vbCrLf & Err.Description ''Открытие любого текстового файла 'CommonDialog1.ShowOpen 'File = CommonDialog1.FileName 'Open File For Input As #1 'Do While Not EOF(1) 'Line Input #1, Strfile 'Loop 'Close #1 End Sub Private Sub Command2_Click() text = Text1.text s = 1 num = 0 sum = 0 pr = 1 If text = "" Then MsgBox "Это значение недопустимо!" & Chr(13) & Chr(10) & " Введите текст!", vbOKOnly + vbExclamation, "Недопустимое значение" On Error GoTo HandlerErr2 End If n = Len(text) ReDim k(1 To n) As String 'ReDim c(1 To n) As Integer For i = 1 To n k(i) = Mid(text, s, 1) If (k(i) >= "0") And (k(i) <= "9") Then num = num + 1 sum = sum + Val(k(i)) pr = pr * Val(k(i)) End If s = s + 1 Next If num = 0 Then Text2.text = "В этом тексте нет цифр." Else Text2.text = "В этом тексте " & Str(num) & " цифр." If Option1.Value = True Then Text2.text = Text2.text & Chr(13) & Chr(10) & _ "Их сумма равна " & Str(sum) & "." End If If Option2.Value = True Then Text2.text = Text2.text & Chr(13) & Chr(10) & _ "Их произведение равно " & Str(pr) & "." End If End If Exit Sub HandlerErr2: MsgBox "Ошибка" & Str$(Err.Number) & " при чтении." & vbCrLf & Err.Description End Sub Private Sub Command3_Click() End End Sub Private Sub Form_Load() Command2.Enabled = False End Sub Private Sub Text1_Change() If Text1.text <> "" Then Command2.Enabled = True End Sub Private Sub Text1_DblClick() Text1.text = "" Text2.text = "" Command2.Enabled = False End Sub