Advertisement
Guest User

Untitled

a guest
May 15th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 3.45 KB | None | 0 0
  1. Option Strict On
  2. Option Explicit On
  3. Public Class Form1
  4.  
  5.  
  6.  
  7.     Function vvod(ByVal t As TextBox) As Integer
  8.         Return CInt(t.Text)
  9.     End Function
  10.  
  11.     Function allstr(ByVal s As String) As String
  12.  
  13.         Try
  14.  
  15.             s = My.Computer.FileSystem.ReadAllText(s)
  16.  
  17.         Catch ex As Exception
  18.  
  19.             MsgBox("Файл не может быть открыт " & " из-за ошибки:" & vbCrLf & vbCrLf & ex.Message)
  20.  
  21.         End Try
  22.  
  23.         Return s
  24.  
  25.     End Function
  26.  
  27.     Sub vvodmas(ByRef x() As String, ByVal f As Short)
  28.  
  29.         Dim i As Integer
  30.         Dim r, y As String
  31.  
  32.         Dim s, s1 As String
  33.  
  34.         If f = 0 Then
  35.  
  36.             s1 = "Фамилии авторов"
  37.             s = "Фамилия"
  38.  
  39.         ElseIf f = 1 Then
  40.  
  41.             s1 = "Имена студентов"
  42.             s = "Имя"
  43.  
  44.         End If
  45.  
  46.         For i = 0 To UBound(x) - 1
  47.  
  48.             r = Str(i + 1)
  49.             y = (InputBox(s + r + "=", s1))
  50.             x(i) = y
  51.         Next
  52.  
  53.     End Sub
  54.  
  55.     Sub povtor(ByVal s() As String)
  56.  
  57.         Dim f As Boolean
  58.         Dim m As Integer = 0
  59.  
  60.  
  61.         For i = 0 To s.Length - 1
  62.  
  63.             f = False
  64.  
  65.             For j = 0 To UBound(stru)
  66.  
  67.                 If (s(i) = stru(j).auth) Then
  68.  
  69.                     f = True
  70.                     stru(j).num = stru(j).num + 1
  71.  
  72.                 End If
  73.  
  74.             Next
  75.  
  76.             If f = False Then
  77.  
  78.                 stru(m).auth = s(i)
  79.                 m = m + 1
  80.  
  81.             End If
  82.  
  83.         Next
  84.         ReDim Preserve stru(m - 1)
  85.  
  86.     End Sub
  87.  
  88.     Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  89.  
  90.         Dim n As Integer
  91.  
  92.         n = vvod(TextBox1)
  93.  
  94.         Dim name_stud, name_auth As String
  95.         Dim stud(n), auth(n) As String
  96.  
  97.         name_stud = allstr("name_stud.txt")
  98.         stud = rasbienie_na_str(name_stud)
  99.         vivodmas(stud, ListBox1)
  100.  
  101.         name_auth = allstr("name_auth.txt")
  102.         vivvod_postr(name_auth, ListBox2)
  103.         'delet_vbnewline(name_auth)
  104.         auth = rasbienie_na_str(name_auth)
  105.  
  106.         ReDim stru(2 * n)
  107.  
  108.         For i = 0 To 2 * n
  109.  
  110.             stru(i).num = 1
  111.  
  112.         Next
  113.  
  114.         povtor(auth)
  115.         vivod_my_type(ListBox3, ListBox4)
  116.  
  117.  
  118.  
  119.  
  120.  
  121.     End Sub
  122.  
  123.     Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
  124.  
  125.         Form2.Show()
  126.  
  127.     End Sub
  128.  
  129.     Sub vvodmas(ByRef x1() As String, ByRef x2() As String)
  130.  
  131.         Dim i As Integer
  132.         Dim r, y As String
  133.  
  134.         Dim s11, s12 As String
  135.         Dim s21, s22 As String
  136.  
  137.  
  138.         s12 = "Студент"
  139.         s11 = "Фамилия студента"
  140.         s22 = "Авторы"
  141.         s21 = "Фамилии авторов"
  142.  
  143.         For i = 0 To UBound(x1) - 1
  144.  
  145.             r = Str(i + 1)
  146.             y = (InputBox(s11 + r + "=", s12))
  147.             x1(i) = y
  148.  
  149.             r = Str(i + 1)
  150.             y = (InputBox(s21 + r + "=", s22))
  151.             x2(i) = y
  152.  
  153.         Next
  154.  
  155.     End Sub
  156.  
  157.     Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  158.  
  159.         Dim n As Integer
  160.  
  161.         n = vvod(TextBox1)
  162.  
  163.         Dim auth(n), numm(n) As String
  164.  
  165.         vvodmas(auth, numm)
  166.  
  167.         vivodmas(auth, ListBox1)
  168.         vivodmas(numm, ListBox2)
  169.         ReDim stru(2 * n)
  170.  
  171.         povtor(auth)
  172.  
  173.         vivod_my_type(ListBox3, ListBox4)
  174.  
  175.  
  176.     End Sub
  177. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement