IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VB 6 et antérieur Discussion :

Variable Facultative vb6


Sujet :

VB 6 et antérieur

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Mai 2014
    Messages
    38
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Autre

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Industrie

    Informations forums :
    Inscription : Mai 2014
    Messages : 38
    Par défaut Variable Facultative vb6
    slt a tous
    quel qu’un peut me dire pourquoi ce code n'enregistre rien ? il marche parfaitement sans les conditions if ismissing.
    je doit faire une enregistrement de 2 tables avec une seul fonction mais 2 forme différente
    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
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    'Class Module
    Option Explicit
     
    Private db As Database
     
    Private v_champ1 As Variant
    Private v_champ2 As Variant
    Private v_champ3 As Variant
    Private v_champ4 As Variant
    Private v_champ5 As Variant
    Private v_champ6 As Variant
    Private v_table As Variant
     
    Public Property Get champ1() As Variant
    champ1 = v_champ1
    End Property
    Public Property Let champ1(a As Variant)
    v_champ1 = a
    End Property
     
    Public Property Get champ2() As Variant
    champ2 = v_champ2
    End Property
    Public Property Let champ2(b As Variant)
    v_champ2 = b
    End Property
     
    Public Property Get champ3() As Variant
    champ3 = v_champ3
    End Property
    Public Property Let champ3(c As Variant)
    v_champ3 = c
    End Property
     
    Public Property Get champ4() As Variant
    champ4 = v_champ1
    End Property
    Public Property Let champ4(d As Variant)
    v_champ4 = d
    End Property
     
    Public Property Get champ5() As Variant
    champ5 = v_champ5
    End Property
    Public Property Let champ5(e As Variant)
    v_champ5 = e
    End Property
     
    Public Property Get champ6() As Variant
    champ6 = v_champ6
    End Property
    Public Property Let champ6(F As Variant)
    v_champ6 = F
    End Property
     
    Public Property Get table() As Variant
    table = v_table
    End Property
    Public Property Let table(g As Variant)
    v_table = g
    End Property
     
    Public Sub insertion(champ1 As Variant, Optional champ2 As Variant, Optional champ3 As Variant, Optional champ4 As Variant, Optional champ5 As Variant, Optional champ6 As Variant)
    Dim m As String
    m = MsgBox("voulez-vous enregistrer?", vbYesNo + vbQuestion, "Enregistrer")
        If m = vbYes Then
            If IsMissing(champ5) And IsMissing(champ6) Then
                db.Execute "INSERT INTO " & v_table & " VALUES ('" & champ1 & "','" & champ2 & "','" & champ3 & "','" & champ4 & "')"
            Else
            If IsMissing(champ3) And IsMissing(champ4) And IsMissing(champ5) And IsMissing(champ6) Then
                db.Execute "INSERT INTO " & v_table & " VALUES ('" & champ1 & "','" & champ2 & "')"
            End If
        End If
    End If
    End Sub
     
     
    Private Sub Class_Initialize()
    Set db = OpenDatabase("E:\Logiciel\DTS\VB6\Access\Bon de commande.mdb")
    End Sub
     
    Private Sub Class_Terminate()
    db.Close
    End Sub
    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
    25
    26
    'Form
    Option Explicit
     
    Private Sub cmdEnregistrer_Click()
    'On Error Resume Next
    Dim x As ProjectDLL.insertion
    Set x = New ProjectDLL.insertion
    x.Table = "Fournisseur"
     
    x.champ1 = "Code FRNS"
    x.champ2 = "Nom FRNS"
    x.champ3 = "Adresse FRNS"
    x.champ4 = "Telephone"
     
    x.champ1 = Text1.Text
    x.champ2 = Text2.Text
    x.champ3 = Text3.Text
    x.champ4 = Text4.Text
     
    x.insertion(text1.text & text2.text & text3.text & text4.text)
    Text1.SetFocus
    Text1.Text = ""
    Text2.Text = ""
    Text3.Text = ""
    Text4.Text = ""
    End Sub

  2. #2
    Expert confirmé
    Avatar de ProgElecT
    Homme Profil pro
    Retraité
    Inscrit en
    Décembre 2004
    Messages
    6 132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 69
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Retraité
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Décembre 2004
    Messages : 6 132
    Par défaut
    Salut

    La condition ismissing ne doit pas être le problème.
    Ligne 20, il me semble que x.insertion(text1.text & text2.text & text3.text & text4.text) devrait être x.insertion text1.text, text2.text, text3.text, text4.textTous tes champs sont déclarés Variant, le fait de passer des Text.text tes variants récepteur de la Sub insertion vont être forcement de type String.
    Si tu veux passer un type précis, il faut passer à ta sub en typant le contenu de tes textbox.
    Exemple de passage d'un chiffre integer dans le Champs1, d'un Boolean dans Champs2, d'un chiffre double dans Champs3 et d'un chiffre long dans Champs4.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    x.insertion Cint(text1.text), CBool(text2.text), CDbl(text3.text), CLng(text4.text)
    :whistle:pourquoi pas, pour remercier, un :plusser: pour celui/ceux qui vous ont dépannés.
    saut de ligne
    OOOOOOOOO👉 → → Ma page perso sur DVP ← ← 👈

  3. #3
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Mai 2014
    Messages
    38
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Autre

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Industrie

    Informations forums :
    Inscription : Mai 2014
    Messages : 38
    Par défaut
    c'est ce que je pense aussi mais il m'affiche cette erreur
    Compil error: expected =

  4. #4
    Expert confirmé
    Avatar de ProgElecT
    Homme Profil pro
    Retraité
    Inscrit en
    Décembre 2004
    Messages
    6 132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 69
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Retraité
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Décembre 2004
    Messages : 6 132
    Par défaut
    J'ai modifié et complété mon premier post.
    :whistle:pourquoi pas, pour remercier, un :plusser: pour celui/ceux qui vous ont dépannés.
    saut de ligne
    OOOOOOOOO👉 → → Ma page perso sur DVP ← ← 👈

  5. #5
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Mai 2014
    Messages
    38
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Autre

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Industrie

    Informations forums :
    Inscription : Mai 2014
    Messages : 38
    Par défaut
    mais ils sont tous de type string. en tout cas merci beaucoup pur tes réponses

  6. #6
    Expert confirmé
    Avatar de ProgElecT
    Homme Profil pro
    Retraité
    Inscrit en
    Décembre 2004
    Messages
    6 132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 69
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Retraité
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Décembre 2004
    Messages : 6 132
    Par défaut
    Enleve le = après x.insertion
    :whistle:pourquoi pas, pour remercier, un :plusser: pour celui/ceux qui vous ont dépannés.
    saut de ligne
    OOOOOOOOO👉 → → Ma page perso sur DVP ← ← 👈

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [CR XI] Probleme passage de Variables entre VB6 et Crystal XI
    Par ACIDEV dans le forum SAP Crystal Reports
    Réponses: 2
    Dernier message: 10/02/2011, 10h41
  2. variable structurée (VB6)
    Par dimdimDC dans le forum VB 6 et antérieur
    Réponses: 3
    Dernier message: 04/10/2007, 21h53
  3. variable de vb6 à CR9
    Par ecranbleu27 dans le forum SDK
    Réponses: 2
    Dernier message: 30/05/2006, 17h05
  4. [VB6] creation de variable de type string dynamiquement
    Par da40 dans le forum VB 6 et antérieur
    Réponses: 10
    Dernier message: 12/06/2003, 17h59
  5. [VB6] [Fichier] Enregistrer des variables de structure
    Par de.bo dans le forum VB 6 et antérieur
    Réponses: 4
    Dernier message: 07/10/2002, 12h09

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo