Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Strict On
- Option Explicit On
- Public Class Form1
- Function vvod(ByVal t As TextBox) As Integer
- Return CInt(t.Text)
- End Function
- Function allstr(ByVal s As String) As String
- Try
- s = My.Computer.FileSystem.ReadAllText(s)
- Catch ex As Exception
- MsgBox("Файл не может быть открыт " & " из-за ошибки:" & vbCrLf & vbCrLf & ex.Message)
- End Try
- Return s
- End Function
- Sub vvodmas(ByRef x() As String, ByVal f As Short)
- Dim i As Integer
- Dim r, y As String
- Dim s, s1 As String
- If f = 0 Then
- s1 = "Фамилии авторов"
- s = "Фамилия"
- ElseIf f = 1 Then
- s1 = "Имена студентов"
- s = "Имя"
- End If
- For i = 0 To UBound(x) - 1
- r = Str(i + 1)
- y = (InputBox(s + r + "=", s1))
- x(i) = y
- Next
- End Sub
- Sub povtor(ByVal s() As String)
- Dim f As Boolean
- Dim m As Integer = 0
- For i = 0 To s.Length - 1
- f = False
- For j = 0 To UBound(stru)
- If (s(i) = stru(j).auth) Then
- f = True
- stru(j).num = stru(j).num + 1
- End If
- Next
- If f = False Then
- stru(m).auth = s(i)
- m = m + 1
- End If
- Next
- ReDim Preserve stru(m - 1)
- End Sub
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- Dim n As Integer
- n = vvod(TextBox1)
- Dim name_stud, name_auth As String
- Dim stud(n), auth(n) As String
- name_stud = allstr("name_stud.txt")
- stud = rasbienie_na_str(name_stud)
- vivodmas(stud, ListBox1)
- name_auth = allstr("name_auth.txt")
- vivvod_postr(name_auth, ListBox2)
- 'delet_vbnewline(name_auth)
- auth = rasbienie_na_str(name_auth)
- ReDim stru(2 * n)
- For i = 0 To 2 * n
- stru(i).num = 1
- Next
- povtor(auth)
- vivod_my_type(ListBox3, ListBox4)
- End Sub
- Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
- Form2.Show()
- End Sub
- Sub vvodmas(ByRef x1() As String, ByRef x2() As String)
- Dim i As Integer
- Dim r, y As String
- Dim s11, s12 As String
- Dim s21, s22 As String
- s12 = "Студент"
- s11 = "Фамилия студента"
- s22 = "Авторы"
- s21 = "Фамилии авторов"
- For i = 0 To UBound(x1) - 1
- r = Str(i + 1)
- y = (InputBox(s11 + r + "=", s12))
- x1(i) = y
- r = Str(i + 1)
- y = (InputBox(s21 + r + "=", s22))
- x2(i) = y
- Next
- End Sub
- Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
- Dim n As Integer
- n = vvod(TextBox1)
- Dim auth(n), numm(n) As String
- vvodmas(auth, numm)
- vivodmas(auth, ListBox1)
- vivodmas(numm, ListBox2)
- ReDim stru(2 * n)
- povtor(auth)
- vivod_my_type(ListBox3, ListBox4)
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement