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

C# Discussion :

Conversion Vb.net C#


Sujet :

C#

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Janvier 2014
    Messages
    28
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Janvier 2014
    Messages : 28
    Par défaut Conversion Vb.net C#
    Bonjour tout,

    J’ai besoin qu’on m’aide à convertir ce programme vb.net en C# :

    Code vb.net : 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
        Private Sub MenuItemConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItemConnect.Click
     
            ' connect to USB-CANmodul (any modul)
            Dim bRet As Byte = 0
            Dim ucanMode As UcanDotNET.USBcanServer.tUcanMode
     
            If Me.m_fIsInst1Initialized <> True Then
     
                ' check if TxEchoMode should be enabled
                If (MenuItemTxEchoMode.Checked() = True) Then
                    ucanMode = UcanDotNET.USBcanServer.tUcanMode.kUcanModeTxEcho
                    m_fTxEchoMode = True
                Else
                    ucanMode = UcanDotNET.USBcanServer.tUcanMode.kUcanModeNormal
                    m_fTxEchoMode = False
                End If
     
                ' init hardware
                Me.m_USBcanInst1 = New UcanDotNET.USBcanServer
                Me.m_USBcanInst2 = New UcanDotNET.USBcanServer  ' you need to call InitHardware/InitCan methods to initialize the second instance, not done in this demo!
                UcanDotNET.USBcanServer.SetDebugMode(&HC0000306, ".\MyLogFile.log")
                bRet = Me.m_USBcanInst1.InitHardware(UcanDotNET.USBcanServer.USBCAN_ANY_MODULE)
                If (bRet = UcanDotNET.USBcanServer.eUcanReturn.USBCAN_SUCCESSFUL) Then
     
                    Debug.WriteLine("InitCan(): baudrate is " + UcanDotNET.USBcanServer.GetBaudrateMessage(UcanDotNET.USBcanServer.eUcanBaudrate.USBCAN_BAUD_500kBit))
     
                    ' init CAN channel 0
                    'UcanDotNET.USBcanServer.USBCAN_BAUD_1MBit, _
                    bRet = Me.m_USBcanInst1.InitCan(UcanDotNET.USBcanServer.eUcanChannel.USBCAN_CHANNEL_CH0, _
                                               UcanDotNET.USBcanServer.eUcanBaudrate.USBCAN_BAUD_1MBit, _
                                               UcanDotNET.USBcanServer.eUcanBaudrateEx.USBCAN_BAUDEX_USE_BTR01, _
                                               UcanDotNET.USBcanServer.USBCAN_AMR_ALL, _
                                               UcanDotNET.USBcanServer.USBCAN_ACR_ALL, _
                                               ucanMode)
                    If (bRet = UcanDotNET.USBcanServer.eUcanReturn.USBCAN_SUCCESSFUL) Then
     
                        Dim HwInfo As UcanDotNET.USBcanServer.tUcanHardwareInfoEx
                        Dim CanInfoCh0 As UcanDotNET.USBcanServer.tUcanChannelInfo
                        Dim CanInfoCh1 As UcanDotNET.USBcanServer.tUcanChannelInfo
     
                        bRet = Me.m_USBcanInst1.GetHardwareInfo(HwInfo, CanInfoCh0, CanInfoCh1)
                        If (bRet = UcanDotNET.USBcanServer.eUcanReturn.USBCAN_SUCCESSFUL) Then
                            m_DeviceNrInst1 = HwInfo.m_bDeviceNr    ' is used to check the instance in event handles
                        End If
                        If ((bRet = UcanDotNET.USBcanServer.eUcanReturn.USBCAN_SUCCESSFUL) AndAlso _
                            (UcanDotNET.USBcanServer.CheckSupportCyclicMsg(HwInfo) = True)) Then
     
                            Dim aCyclicCanMsg(1) As UcanDotNET.USBcanServer.tCanMsgStruct
                            Dim aCyclicCanMsgReadBack(1) As UcanDotNET.USBcanServer.tCanMsgStruct
     
                            aCyclicCanMsg(0) = UcanDotNET.USBcanServer.tCanMsgStruct.CreateInstance(&H61F)
                            aCyclicCanMsg(0).m_bData(0) = &H40
                            aCyclicCanMsg(0).m_bData(1) = &H0
                            aCyclicCanMsg(0).m_bData(2) = &H10
                            aCyclicCanMsg(0).m_bData(3) = &H0
                            aCyclicCanMsg(0).m_dwTime = 1000    ' 1 second
     
                            aCyclicCanMsg(1) = UcanDotNET.USBcanServer.tCanMsgStruct.CreateInstance(&H71F, UcanDotNET.USBcanServer.eUcanMsgFrameFormat.USBCAN_MSG_FF_RTR)
                            aCyclicCanMsg(1).m_bDLC = 1
                            aCyclicCanMsg(1).m_dwTime = 1200    ' 1.2 seconds
     
                            bRet = Me.m_USBcanInst1.DefineCyclicCanMsg(UcanDotNET.USBcanServer.eUcanChannel.USBCAN_CHANNEL_CH0, aCyclicCanMsg)
                            bRet = Me.m_USBcanInst1.ReadCyclicCanMsg(UcanDotNET.USBcanServer.eUcanChannel.USBCAN_CHANNEL_CH0, aCyclicCanMsgReadBack)
                            bRet = Me.m_USBcanInst1.EnableCyclicCanMsg(UcanDotNET.USBcanServer.eUcanChannel.USBCAN_CHANNEL_CH0, _
                                UcanDotNET.USBcanServer.eUcanCyclicFlags.USBCAN_CYCLIC_FLAG_START)
     
                        End If
     
                        ' init CAN channel 1
                        bRet = Me.m_USBcanInst1.InitCan(UcanDotNET.USBcanServer.eUcanChannel.USBCAN_CHANNEL_CH1, _
                                               UcanDotNET.USBcanServer.eUcanBaudrate.USBCAN_BAUD_1MBit, _
                                               UcanDotNET.USBcanServer.eUcanBaudrateEx.USBCAN_BAUDEX_USE_BTR01, _
                                               UcanDotNET.USBcanServer.USBCAN_AMR_ALL, _
                                               UcanDotNET.USBcanServer.USBCAN_ACR_ALL, _
                                               ucanMode)
                        If (bRet = UcanDotNET.USBcanServer.eUcanReturn.USBCAN_SUCCESSFUL) Then
                            ' multi channel USB-CANmodul is present
                            Me.m_f2ndChannelInst1 = True
                            Me.StatusBarPanelText.Text = "Successfully connected to multi-channel USB-CANmodul"
                        Else
                            ' single channel USB-CANmodul is present
                            Me.StatusBarPanelText.Text = "Successfully connected to single-channel USB-CANmodul"
                        End If
                        Me.m_fIsInst1Initialized = True
     
                        Me.m_RxThread = New Thread(AddressOf Me.ThreadProcReceive)
                        Me.m_RxThread.Start()
     
                    Else ' error while CAN channel 0 init
                        Me.m_USBcanInst1.Dispose()
                        Me.m_USBcanInst1 = Nothing
                        Me.StatusBarPanelText.Text = "Initialisation of CAN failed"
                    End If
     
                Else  ' error while hardware init
                    Me.m_USBcanInst1.Dispose()
                    Me.m_USBcanInst1 = Nothing
                    Me.StatusBarPanelText.Text = "Initialisation of Hardware failed"
                End If
     
                Me.StatusBarPanelCode.Text = bRet.ToString("X2")
     
                If m_fIsInst1Initialized = True Then
                    MenuItemConnect.Enabled = False
                    MenuItemShutdown.Enabled = True
                End If
            Else
                Me.StatusBarPanelText.Text = "Already Connected"
            End If
     
        End Sub

    je vous remercie.

  2. #2
    Modérateur
    Avatar de DotNetMatt
    Homme Profil pro
    CTO
    Inscrit en
    Février 2010
    Messages
    3 611
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : Etats-Unis

    Informations professionnelles :
    Activité : CTO
    Secteur : Finance

    Informations forums :
    Inscription : Février 2010
    Messages : 3 611
    Billets dans le blog
    3
    Par défaut
    Il y a plein d'outils sur le net pour faire ça... Une recherche sur Google de l'expression "conversion C# VB.NET" te les indiquera.
    Less Is More
    Pensez à utiliser les boutons , et les balises code
    Desole pour l'absence d'accents, clavier US oblige
    Celui qui pense qu'un professionnel coute cher n'a aucune idee de ce que peut lui couter un incompetent.

  3. #3
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Janvier 2014
    Messages
    28
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Janvier 2014
    Messages : 28
    Par défaut
    D’accord merci.

Discussions similaires

  1. [Débutant] Conversion VB.Net vers C#
    Par Rosees dans le forum C#
    Réponses: 4
    Dernier message: 01/10/2013, 16h08
  2. [Débutant] Conversion C#.net vers VB.net
    Par patrickvier dans le forum VB.NET
    Réponses: 5
    Dernier message: 23/01/2013, 15h08
  3. [Débutant] Conversion application .NET Framework 4.0 en .NET Framework 3.5
    Par Official dans le forum C#
    Réponses: 7
    Dernier message: 06/07/2012, 16h29
  4. Conversion vb.net à java
    Par khaoulalak dans le forum VB.NET
    Réponses: 0
    Dernier message: 05/01/2011, 08h52
  5. ConversioN C++.net vers visual C++ mfc
    Par ricky78 dans le forum MFC
    Réponses: 5
    Dernier message: 13/06/2007, 17h03

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