Подскажите пожалуйста!
- Код: Выделить всё
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim obj, objLav As System.IO.StreamReader, _
strText, strName As String, strEx As Char, ind, leng As Integer, _
arUch() As String = Nothing, _
famInf() As String = Nothing, _
fnt As New Font("Comic Sans MS", 12, FontStyle.Regular)
Try
obj = System.IO.File.OpenText("Ученые.txt")
arUch = Regex.Split(obj.ReadToEnd, vbCrLf)
strName = txtUchP.Text
For Each uchen As String In arUch
famInf = Regex.Split(uchen, " - ")
ind = uchen.IndexOf(strName)
If ind <> -1 Then
If ind < 3 Then
rtxtUch.Text = famInf(0).TrimEnd & " " & famInf(1) & vbCrLf
rtxtUch.Font = fnt
End If
End If
Next
obj.Close()
Catch Ex As IO.FileNotFoundException
MsgBox("К сожалению не найден файл Ученые.txt.", _
MsgBoxStyle.Critical, "Ошибка")
Catch ex As Exception
MsgBox("Произошла следующая ошибка: " & ex.Message, _
MsgBoxStyle.Critical, "Ошибка")
Finally
Me.Focus()
End Try
End Sub