Probleme de dll

mastercatz Messages postés 193 Date d'inscription jeudi 4 décembre 2003 Statut Membre Dernière intervention 12 août 2010 - 17 févr. 2004 à 11:53
mastercatz Messages postés 193 Date d'inscription jeudi 4 décembre 2003 Statut Membre Dernière intervention 12 août 2010 - 17 févr. 2004 à 14:38
Voila mon probleme, je voulais faire une petite dll en vb pour quelques fonctions mais j'ai un probleme. Quand j'appelle ma fonction de la dll j'ai une erreur qui dit 'Point d'entrée introuvable dans la dll'
J'ai feuilleté un peu partout mais sans success. Voici le code de la dll et sa declaration dans le prog

Public Function b2d(bin As Long) As Long

Dim b1 As Integer
Dim b2 As Integer
Dim b3 As Integer
Dim b4 As Integer
Dim b5 As Integer
Dim b6 As Integer
Dim b7 As Integer
Dim b8 As Integer

b1 = Right(bin, 1)
b2 = InStr(bin, 7, 1)
b3 = InStr(bin, 6, 1)
b4 = InStr(bin, 5, 1)
b5 = InStr(bin, 4, 1)
b6 = InStr(bin, 3, 1)
b7 = InStr(bin, 2, 1)
b8 = InStr(bin, 1, 1)

If b1 <> 1 Or b1 <> 0 Then
b2d = -1
Exit Function
End If
If b2 <> 1 Or b2 <> 0 Then
b2d = -1
Exit Function
End If
If b3 <> 1 Or b3 <> 0 Then
b2d = -1
Exit Function
End If
If b4 <> 1 Or b4 <> 0 Then
b2d = -1
Exit Function
End If
If b5 <> 1 Or b5 <> 0 Then
b2d = -1
Exit Function
End If
If b6 <> 1 Or b6 <> 0 Then
b2d = -1
Exit Function
End If
If b7 <> 1 Or b7 <> 0 Then
b2d = -1
Exit Function
End If
If b8 <> 1 Or b8 <> 0 Then
b2d = -1
Exit Function
End If

b2d = (b1 * (2 ^ 0)) + (b2 * (2 ^ 1)) + (b3 * (2 ^ 2)) + (b4 * (2 ^ 3)) + (b5 * (2 ^ 4)) + (b6 * (2 ^ 5)) + (b7 * (2 ^ 6)) + (b8 * (2 ^ 7))

End Function

Dans le prog :

Private Declare Function b2d Lib "C:\binhexdec.dll" (bin As Long) As Long

Private Sub Command1_Click()
MsgBox b2d(Text1.Text)
End Sub

6 réponses

cs_labout Messages postés 1356 Date d'inscription samedi 8 décembre 2001 Statut Membre Dernière intervention 23 octobre 2006 8
17 févr. 2004 à 12:27
labout

Il faut mettre après option explicit

Private Mydll As le Nom de ta dll

Puis pour l'utilisation

MsgBox mydll(Text1.Text)

@+
0
cs_rene38 Messages postés 1858 Date d'inscription samedi 29 juin 2002 Statut Membre Dernière intervention 17 octobre 2013 11
17 févr. 2004 à 12:45
Bonjour

je ne comprends pas bien ton code :
tu mélanges texte et nombres

MsgBox b2d(Text1.Text)
Function b2d(bin As Long) As Long

la fonction attend un Long (nombre) et tu lui passes un texte

b1 = Right(bin, 1) : le caractère de droite d'un nombre ?

b2 = InStr(bin, 7, 1) : je suppose que tu voulais écrire
b2 = Mid(bin, 7, 1)
mais là encore, le septième caractère d'un nombre ???
---------------------------------------
A mon avis, modifications à faire :

Function b2d(bin As String) As Long
b1 = CInt(Right(bin, 1))
b2 = CInt(Mid(bin, 7, 1))
b3 = CInt(Mid(bin, 6, 1))
b4 = CInt(Mid(bin, 5, 1))
b5 = CInt(Mid(bin, 4, 1))
b6 = CInt(Mid(bin, 3, 1))
b7 = CInt(Mid(bin, 2, 1))b8 CInt(Mid(bin, 1, 1)) ou b8 CInt(Left(bin, 1))

ça ne résout pas le problème du point d'entrée
(quoique) mais ça me paraît indispensable.
0
mastercatz Messages postés 193 Date d'inscription jeudi 4 décembre 2003 Statut Membre Dernière intervention 12 août 2010
17 févr. 2004 à 13:58
J'ai tenu compte de vos remarques et j'ai donc modifié mon code. Mais j'obtient une erreur 'Variale objet ou variable bloc With non definie' avec un point d'arret sur l'appel a ma fonction. J'ai essayé de modifier des trucs mais sans succes :

dll:

Public Function b2d(bin As String) As Integer

Dim b1 As Integer
Dim b2 As Integer
Dim b3 As Integer
Dim b4 As Integer
Dim b5 As Integer
Dim b6 As Integer
Dim b7 As Integer
Dim b8 As Integer

b1 = CInt(Right(bin, 1))
b2 = CInt(Mid(bin, 7, 1))
b3 = CInt(Mid(bin, 6, 1))
b4 = CInt(Mid(bin, 5, 1))
b5 = CInt(Mid(bin, 4, 1))
b6 = CInt(Mid(bin, 3, 1))
b7 = CInt(Mid(bin, 2, 1))
b8 = CInt(Mid(bin, 1, 1))

b2d = (b1 * (2 ^ 0)) + (b2 * (2 ^ 1)) + (b3 * (2 ^ 2)) + (b4 * (2 ^ 3)) + (b5 * (2 ^ 4)) + (b6 * (2 ^ 5)) + (b7 * (2 ^ 6)) + (b8 * (2 ^ 7))

End Function

prog :

Option Explicit
Private bhd As binhexdec.b2d

Private Sub Command1_Click()
Dim a As String

a = CStr(Text1.Text)

MsgBox bhd(a)

End Sub
0
cs_labout Messages postés 1356 Date d'inscription samedi 8 décembre 2001 Statut Membre Dernière intervention 23 octobre 2006 8
17 févr. 2004 à 14:19
labout
J'avais oublié une étape

j'ai fait une class class1 avce ta fonction

Option Explicit
Private m_B2 As Class1

Private Sub Form_Load()
Dim a As String
Set m_B2 = New Class1
a = CStr("1")

MsgBox m_B2.b2d(a)

End Sub

Mais j'ai une erreur dans ta classe c'est autre chose à toi de voir.
@+
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
mastercatz Messages postés 193 Date d'inscription jeudi 4 décembre 2003 Statut Membre Dernière intervention 12 août 2010
17 févr. 2004 à 14:37
Moi j'obtient une erreur de type incompatible mais je vois vraiment pas ou ...
0
mastercatz Messages postés 193 Date d'inscription jeudi 4 décembre 2003 Statut Membre Dernière intervention 12 août 2010
17 févr. 2004 à 14:38
Moi j'obtient une erreur de type incompatible mais je vois vraiment pas ou ...
0
Rejoignez-nous