bonjour, j'ai vraiment du mal à convertir une méthode qui avait été écrite en Vb6 pour la mettre en C#.net

Après plusieurs recherche et avoir utilisé un site de conversion qui me donnait plein d'erreur, je solicite votre aide.

Voici le code en VB6:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 
Public Function Supervision1(ByVal bit As Integer, ByVal indice As Integer) As Integer
        Dim nbc As Integer
        Dim line As String
        Dim Str As String
        Dim nbByte As Integer
        Dim i As Integer
        Dim Start As Integer
        Dim nval As Long
        Dim Oct As Integer
        Dim Rank As Integer
        On Error Resume Next
        Rank = indice
        nbc = Len(bit) Mod 2
        'Mise au format &Hxx -> on complète par 0 si besoin
        Str = IIf(nbc = 1, "0" & bit, bit)
        While Rank <= 31 And Len(Str) >= 8
            Str = Mid(Str, Len(Str) - 4)
            Rank = Rank - 16
        End While
        nval = Val("&H" & Str)
        i = Val(Str And CStr(Hex(2 ^ Rank)))
        Supervision1= IIf((nval And 2 ^ Rank) > 0, 1, 0)
    End Function
J'arrive pas à trouver l'équivalent de:
Len
et la mise au format Hex.


Merci de votre aide