Option Strict On
Module Module1
    Function f(ByVal x As Double) As Double
        Return Math.Exp(-x) - x
    End Function
    Function Dihotomy(ByVal a As Double, _
                      ByVal b As Double, _
                      ByVal Fa As Double, _
                      ByVal Fb As Double, _
                      ByVal eps As Double) As Double
        Dim c As Double = (a + b) / 2
        If Math.Abs(b - a) < 2 * eps Then
            Return c
        Else
            Dim Fc As Double = f(c)
            If Math.Sign(Fa) <> Math.Sign(Fc) Then
                Return Dihotomy(a, c, Fa, Fc, eps)
            Else
                Return Dihotomy(c, b, Fb, Fc, eps)
            End If
        End If
    End Function
    Sub Main()
        Dim eps As Double = 0.000001
        Dim a As Double = 0
        Dim b As Double = 1
        Dim c As Double = Dihotomy(a, b, f(a), f(b), eps)
        Console.WriteLine("Решение:  x={0}", c)
        Console.ReadLine()
    End Sub

End Module
