4.10.3-1. , , . :
- , ;
- , ;
, .
. 4.10.3-1.
- Perevorot(), , s, temp s temp .
- Resh(), , . Resh() : Rf StreamReader, , wf StreamWriter, .
. 4.10.3-1. 10.3-1
, wf True, , WriteLine() .
, DelProb() Mas(). Mas() Perevorot().
Join() line2, .
. 4.10.3-2.
' . ' . ' ' ' Option Strict On Option Explicit On Imports System.IO Public Class Form1 ' Function Perevorot(ByVal s As String) As String Dim temp As String = "" Dim L As Integer = s.Length For i As Integer = L - 1 To 0 Step -1 temp = temp + s.Substring(i, 1) Next Return temp End Function ' ' Sub DelProb(ByRef s As String) s = s.Trim Do While s.IndexOf(Space(2)) >= 0 s = s.Replace(Space(2), Space(1)) Loop End Sub Sub Resh(ByVal filename1 As String, _ ByVal filename2 As String,_ ByRef Lb1 As ListBox, ByRef Lb2 As ListBox) ' Dim Rf As New StreamReader(filename1) ' ' True 2- , ' Dim wf As New StreamWriter(filename2, True) Dim line1, line2, slovo As String Dim Mas() As String Try Do While Not Rf.EndOfStream() ' line1 = Rf.ReadLine() ' 1 line1 Lb1.Items.Add(line1) ' line1 ListBox DelProb(line1) ' line1 Mas = Split(line1, " ") ' line1 line2 = "" ' For i As Integer = 0 To Mas.Length - 1 slovo = Mas(i) ' - ' Mas(i) = Perevorot(slovo) Next ' line2, ' line2 = Join(Mas, " ") wf.WriteLine(line2) ' line2 2 Lb2.Items.Add(line2) ' line2 ListBox Loop Catch ex As Exception MsgBox(" ") Finally wf.Flush() ' Rf.Close() ' wf.Close() End Try End Sub Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click Dim filename1 As String = "", filename2 As String = "" filename1 = TextBox1.Text filename2 = TextBox2.Text Resh(filename1, filename2, ListBox1, ListBox2) End Sub Private Sub Button2_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) End End Sub End Class |
|
|
. 4.10.3-2. 10
4.10.3-2. , , . :
- Perevorot() , ;
- Reshenie(), , My.Computer.FileSystem, - ;
vivodFile() , .2, ;
, , .
. 4.10.3-3
- Perevorot(), , s, temp s temp .
Reshenie(), filename, , s1 s2 , . My.Computer.FileSystem s1, Split() Stroki() (vbNewLine). DelProb() , slova() . - Perevorot() s2 . s2 (vbNewLine) , .
|
|
vivodFile(), filename, , S .
Option Strict On Option Explicit On Public Class Form1 ' Function Perevorot(ByVal s As String) As String Dim temp As String = "" Dim L As Integer = s.Length For i As Integer = L - 1 To 0 Step -1 temp = temp + s.Substring(i, 1) Next Return temp End Function ' ' Sub DelProb(ByRef s As String) s = s.Trim Do While s.IndexOf(Space(2)) >= 0 s = s.Replace(Space(2), Space(1)) Loop End Sub ' 's1 s2 Sub Reshenie(ByVal filename As String, ByRef s1 As String, _ ByRef s2 As String) Dim line, OdnoSlovo As String Dim Stroki() As String ' Dim slova() As String ' . s2 = "" ' ' ' s1 Try s1 = My.Computer.FileSystem.ReadAllText(filename) Stroki = s1.Split(CChar(vbNewLine)) ' For i As Integer = 0 To Stroki.Length - 1 line = Stroki(i) ' DelProb(line) ' slova = line.Split(CChar(" ")) ' For j As Integer = 0 To slova.Length - 1 OdnoSlovo = Perevorot(slova(j)) s2 = s2 + OdnoSlovo + " " Next s2 = s2 + vbNewLine Next Catch ex As Exception MsgBox(" - " & _ " :" & vbNewLine & vbCrLf & _ ex.Message) End Try End Sub ' Sub vivodFile(ByVal filename As String, ByVal S As String) ' - S (False) Try My.Computer.FileSystem.WriteAllText(filename, S, False) Catch ex As Exception MsgBox(" () ") MsgBox(" -" _ & " :" & vbNewLine & ex.Message) End Try End Sub Private Sub Button1_Click(...) Dim filename1, filename2 As String Dim OldStr, NewStr As String filename1 = TextBox1.Text filename2 = TextBox2.Text Reshenie(filename1, OldStr, NewStr) vivodFile(filename2, NewStr) TextBox3.Text = OldStr TextBox4.Text = NewStr End Sub End Class |
. 4.10.3-3. 10
1.
1) , ,
|
|
2) , ,
3) , ,
4) ,
2.
1)
2)
3)
4)
3.
1) ,
2) ,
3) ,
4) ,
4.
1) , ,
2) , ,
3) , ,
4) ,,
5)
5. Vb
1) System.IO
2) My.Comhuter.System
3)
4)
6. ReadLine()
1)
2)
3)
4)
7. ReadToEndLine()
1)
2)
3)
8. ,
1) Dim t As New StreamWriter("f[le1.txt", True)
2) Dim t As New StreamWriter("f[le1.txt", False)
3) Dim t As StreamWriter("f[le1.txt")
4)
9. ReadAllText()
1) My.Computer.FileSystem
2) -
3)
10. WriteAllText()
1)
2)
3)
11.
1) StreamWriter.WriteAllText("Hello")
2) My.Computer.FileSystem.WriteAllText("file1.txt","Hello", False)
3) My.Computer.FileSystem.WriteAllText("file1.txt", "Hello", True)
4)
12. WriteAllText()
1) 3
2) 2
3) 1
4) 1, 2 3
5)
13. ReadAllText()
1) 3
2) 2
3) 1
4) 1, 2 3
5)
14. ReadToEnd()
1) ( ) *
2) null,
3)
4) 0,
15. ReadLine()
1) ( )
2) null,
3) *
4) 0,
16. ReadLine()
1) -1
2) 0
3) null
4) EndOfStream
17. Length FileStream :
|
|
1)
2) +:
3) .
18. filename.txt ,
Sub readfile1(ByVal filename As String, ByRef p As String) Dim Rf As StreamReader Rf = New StreamReader(filename) Try p = Rf.ReadToEnd(): Rf.close() Catch ex As Exception MsgBox(" ") End Try End Sub |
1) filename.txt
2) ,
3) FileNotFoundException
4) IOException
19.
Sub writefile1(ByVal filename As String, ByVal p As String) If File.Exists(filename)Then MsgBox(" " & filename & " ") Exit Sub End If Dim wf As New StreamWriter(filename) wf.WriteLine(p): wf.Close() ' End Sub |
1) , filename.txt *
2) ,
3) FileNotFoundException
4) IOException
5) filename.txt c
20. ,
Sub writefile1(ByVal filename As String, ByVal p As String) If File.Exists(filename)Then MsgBox(" " & filename & " ") Exit Sub End If Dim wf As StreamWriter= File.CreateText(filename) wf.WriteLine(p): wf.Close() End Sub |
1) , filename.txt
2) ,
3) FileNotFoundException
4) IOException
5) , *
21.
4.10.7. ,
: , , , ,
,
1) . .
2) VB .
3) .
4) VB .
5) StreamReader, StreamWriter My.Computer.FileSystem .
1) , ( 10).
2) -10.
3) .
4) Microsoft Windows 5-7 , .
5) , : , , .
6) , (. 9), / . , .
7) , , .
8) , .
9) .
10) .
1) | , , . |
2) | , , : , ("" ""), , - . |
3) | , , |
4) | , . |
5) | , - . |
6) | , , - . |
7) | , . |
8) | , . |
9) | , , . , . . |
10) | , , . |
11) | , , . |
12) | . |
13) | , . |
14) | "mm-dd-yyyy", mm - , dd - , yyyy - . , , "dd.mm.yy", yy - . |
15) | , , "" , "XXXXX" "nX", X - , n - . |
16) | , . |
17) | , . |
18) | . |
19) | , , (a, e, i, o, u, y). |
20) | , , . |
21) | , , . |
22) | , , .. . |
23) | , . |
24) | , "dd.mm.yy", dd - , mm - , yy - , , n , . |
25) | , . |
26) | , . |
27) | , n- . |
28) | , "" 10 , , 10*(k - 1) + 1, k - "". |
, ʻ . | |
30) | , "dd.mm.yy", dd - , mm - , yy - , , n , . |
|
|
4.10.7.4.
1) ;
2) , , , .
3) .
4) .
5) , :
5.1) ;
5.2) ;
5.3) ;
5.4) .
6) .
7) .