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

Développement Windows Discussion :

Migrer mon code VBA vers VB.net ou C#


Sujet :

Développement Windows

  1. #1
    Candidat au Club
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Juin 2019
    Messages
    5
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 34
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Technicien maintenance

    Informations forums :
    Inscription : Juin 2019
    Messages : 5
    Points : 3
    Points
    3
    Par défaut Migrer mon code VBA vers VB.net ou C#
    Bonjour,
    j'ai codé un petit programme en VBA et je souhaiterais faire la même chose mais en VB.NET ou C# mais je ne connais pas vraiment c'est 2 langage, si vous pouvez m'aider ça serait vraiment top
    Merci

    Code VBA : 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
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    Private Sub btn_localisation_Click() 'Recherche par localisation
    On Error GoTo 1
     Sheets("Base").Activate
     
     ActiveSheet.Range("$G$3:$G$1000").AutoFilter Field:=7, Criteria1:=Me.TextBox_localisation.Value
     
    1
    End Sub
     
    Private Sub btn_Reset_Click() 'Reset Filtre
    On Error GoTo 1
    TextBox6.Value = ""
    TextBox_localisation.Value = ""
    TextBox1 = ""
    TextBox2 = ""
    TextBox3 = ""
    TextBox4 = ""
    TextBox5 = ""
    TextBox8 = ""
    TextBox9 = ""
    TextBox10 = ""
    Worksheets("Base").ShowAllData
     
     
     
    1
    End Sub
     
    Private Sub btn_type_Click() 'Recherche par Type
    On Error GoTo 1
     Sheets("Base").Activate
        ActiveSheet.Range("$D$3:$D$1000").AutoFilter Field:=4, Criteria1:=TextBox_type.Value
    1
    End Sub
     
    Private Sub btnFermer_Click() 'Fermer programme
     
     
        Unload Me
     
    End Sub
     
    Private Sub ComboBox1_Change()
     
    End Sub
     
    Private Sub CommandButton1_Click() 'Filtrer liste par DN
    On Error GoTo 1
     Sheets("Base").Activate
        ActiveSheet.Range("$B$3:$B$1000").AutoFilter Field:=2, Criteria1:=Me.TextBox6.Value
     
      'compte le nombre de DN filtré
      Dim NoLigne(), i, j
        For Each ligne In Sheets("Base").AutoFilter.Range.SpecialCells(xlCellTypeVisible).Rows
            i = i + 1
            ReDim Preserve NoLigne(i)
            NoLigne(i) = ligne.Address(RowAbsolute:=False, ColumnAbsolute:=False)
        Next
        For j = 1 To i
            TextBox11 = NoLigne(j)
        Next
     
    1
    End Sub
     
    Private Sub CommandButton3_Click()
    'Gestion des erreurs
        On Error GoTo 1
     
        'test si le numéro de vanne existe
        If WorksheetFunction.CountIf(Sheets("Base").Range("A:A"), Me.TextBox1.Value) = 0 Then
     
            ' affiche un message qui indique que la vanne n'a pas était trouvé
            MsgBox "Cette vanne n'éxiste pas. Veuillez saisir un nouveau TAG", vbInformation + vbOKOnly, "Vanne non trouvé"
     
            End If
     
            With Me 'avec le forumlaire:
     
                'Applique la fonction RechercheV (Vlookup) pour afficher les informations de la vanne
                .TextBox2 = Application.WorksheetFunction.VLookup(CStr(Me.TextBox1), Sheets("Base").Range("source"), 2, 0) 'affiche DN
                .TextBox3 = Application.WorksheetFunction.VLookup(CStr(Me.TextBox1), Sheets("Base").Range("source"), 3, 0) 'affiche Etage
                .TextBox4 = Application.WorksheetFunction.VLookup(CStr(Me.TextBox1), Sheets("Base").Range("source"), 4, 0) 'affiche Type
                .TextBox5 = Application.WorksheetFunction.VLookup(CStr(Me.TextBox1), Sheets("Base").Range("source"), 5, 0) 'affiche Périodicté Préventive
                .TextBox8 = Application.WorksheetFunction.VLookup(CStr(Me.TextBox1), Sheets("Base").Range("source"), 7, 0) 'affiche la Localisation
                .TextBox9 = Application.WorksheetFunction.VLookup(CStr(Me.TextBox1), Sheets("Base").Range("source"), 8, 0) 'affiche Code SAP
                .TextBox10 = Application.WorksheetFunction.VLookup(CStr(Me.TextBox1), Sheets("Base").Range("source"), 6, 0) 'affiche Description Equipement
     
     
     
            End With
     
    1
    End Sub
     
    Private Sub CommandButton4_Click() 'Bouton active filtre
     
    If CommandButton4.BackColor = &H8000000F Then CommandButton4.BackColor = RGB(0, 255, 0) Else If CommandButton5.BackColor = RGB(255, 0, 0) Then CommandButton5.BackColor = &H8000000F Else CommandButton5.BackColor = &H8000000F
     
     
     ActiveSheet.Range("$A$3:$H$1000").AutoFilter Field:=2, Criteria1:=Me.TextBox6.Value
     Sheets("Base").ShowAllData
     
     
    End Sub
     
    Private Sub CommandButton5_Click() 'bouton desactive filtre
    If CommandButton5.BackColor = &H8000000F Then CommandButton5.BackColor = RGB(255, 0, 0) Else If CommandButton4.BackColor = RGB(0, 255, 0) Then CommandButton4.BackColor = &H8000000F Else CommandButton4.BackColor = &H8000000F
     
    ActiveSheet.AutoFilterMode = False
    TextBox6.Value = ""
    End Sub

  2. #2
    Membre du Club
    Profil pro
    Inscrit en
    Juillet 2006
    Messages
    82
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2006
    Messages : 82
    Points : 47
    Points
    47
    Par défaut
    Un peu tard vu la date de ton post... mais bon. Si tu utilisais excel via une macro vba. Côté .net tu dois utiliser les objects COM.

    https://docs.microsoft.com/fr-fr/off...sual-basic-net

Discussions similaires

  1. traduire un code vba vers vb.net
    Par houssine77100 dans le forum VB.NET
    Réponses: 3
    Dernier message: 21/11/2010, 13h15
  2. Comment verouiller mon code vba?
    Par Subkill dans le forum Macros et VBA Excel
    Réponses: 3
    Dernier message: 11/06/2007, 19h06
  3. Comment convertir mon code ASP et ASP.Net ?
    Par yushkoya dans le forum ASP.NET
    Réponses: 3
    Dernier message: 25/07/2006, 17h24
  4. afficher un graphique dans word à partir de mon code vba
    Par guysocode dans le forum VBA Word
    Réponses: 2
    Dernier message: 07/11/2005, 14h15
  5. [VB.net]problème de conversion de code c# vers VB.net
    Par cladsam dans le forum Windows Forms
    Réponses: 2
    Dernier message: 18/10/2005, 14h07

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