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

WinDev Discussion :

convertir du code vb en windev


Sujet :

WinDev

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé
    Inscrit en
    Février 2006
    Messages
    231
    Détails du profil
    Informations forums :
    Inscription : Février 2006
    Messages : 231
    Par défaut convertir du code vb en windev
    j'ai un bout de code écrite en visual basic et j'aimerais bien la traduire en du code windev.(le code est écrit dans un document txt)
    c'est un code pour ouvrir un tiroir caisse (USB).Merci pour votre aide.
    **********Voici le code***************
    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
    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
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    MainForm - 1 
    Option Explicit 
    Dim DrawerHandle As Long 
    Dim DrawerNumber As Byte 
    'DLL functions used to communicate with the USB device 
    Private Declare Function OpenDrawer Lib "MSPOS_USB.dll" (ByVal DeviceHandle As Long) As Integer 
    Private Declare Function GetDrawerStatus Lib "MSPOS_USB.dll" (ByVal DeviceHandle As Long) As Int 
    eger 
    Private Declare Function ReleaseDrawerHandle Lib "MSPOS_USB.dll" (ByVal DeviceHandle As Long) As 
    Integer 
    Private Declare Function GetDrawerHandle Lib "MSPOS_USB.dll" (ByVal DrawerNumber As Byte) As Lon 
    g 
    Private Sub DrawerOption_Click(Index As Integer) 
    DrawerNumber = Index 'Get the new drawer ID number 
    If DrawerHandle > 0 Then 'Check to see if we already have a valid handle 
    'If so release the handle call "ReleaseDrawerHandle" 
    Call ReleaseDrawerHandle(DrawerHandle) 
    DrawerHandle = 0 'Reset the handle to 0 
    End If 
    Call Status_Button_Click 'Call the "Get Status" button routine 
    End Sub 
    Private Sub Form_Load() 
    'Set default properties 
    Status.Caption = "USB Device NOT Connected!" 
    Status.ForeColor = &HFF 
    Shape1.BorderColor = &H0 
    Shape1.FillColor = &H0 
    Label2.Caption = "OFFLINE" 
    Open_Button.Enabled = False 
    Status_Button.Enabled = False 
    mnuCashDrawer.Enabled = False 
    DrawerHandle = 0 
    End Sub 
    Private Sub Form_Terminate() 
    'If we have a valid handle then release it 
    If DrawerHandle > 0 Then Call ReleaseDrawerHandle(DrawerHandle) 
    End 
    End Sub 
    Private Sub Form_Unload(Cancel As Integer) 
    'If we have a valid handle then release it 
    If DrawerHandle > 0 Then Call ReleaseDrawerHandle(DrawerHandle) 
    End 
    End Sub 
    Private Sub mnuAbout_Click() 
    AboutForm.Show 1 
    End Sub 
    Private Sub mnuExit_Click() 
    'If we have a valid handle then release it 
    If DrawerHandle > 0 Then Call ReleaseDrawerHandle(DrawerHandle) 
    End 
    End Sub 
    Private Sub mnuOnline_Click() 
    Call Status_Button_Click 
    End Sub 
    Private Sub mnuOpenDrawer_Click() 
    Call Open_Button_Click 
    End Sub 
    Private Sub mnuStatusDrawer_Click() 
    MainForm - 2 
    Call Status_Button_Click 
    End Sub 
    Private Sub Open_Button_Click() 
    Dim Result As Integer 
    Call GetHandle 'Get a handle for the device if we do not have one 
    If DrawerHandle = 0 Then Exit Sub 'If not valid then exit 
    Result = OpenDrawer(DrawerHandle) 'Else call "OpenDrawer" function 
    'Catch errors on the USB Device 
    If Result = 0 Then 'If it returned a 0 we had an error 
    Call USBError 
    End If 
    End Sub 
    Private Sub USBError() 
    'This gets called when there was a reported error getting or sending data 
    'from the USB bus and the device. This sub will set the form porperties to 
    'not allow user interaction if the device communication failed. 
    Status.Caption = "USB Device NOT Connected!" 
    Status.ForeColor = &HFF 
    Shape1.BorderColor = &H0 
    Shape1.FillColor = &H0 
    Label2.Caption = "OFFLINE" 
    Open_Button.Enabled = False 
    Status_Button.Enabled = False 
    mnuCashDrawer.Enabled = False 
    Call ReleaseDrawerHandle(DrawerHandle) 
    DrawerHandle = 0 
    End Sub 
    Private Sub Status_Button_Click() 
    Dim Result As Integer 
    Call GetHandle 'Get a handel for teh device if we do not have one 
    If DrawerHandle = 0 Then Exit Sub 'If not valid then exit 
    Result = GetDrawerStatus(DrawerHandle) 'Else call "GetDrawerStatus" function 
    If Result = 0 Then 'If it returned a 0 we had an error 
    Call USBError 
    ElseIf Result = 2 Then 'If it returned a 2 we have an open cash drawer 
    Label2.Caption = "OPEN" 
    Shape1.FillColor = &HFF00& 
    Shape1.BorderColor = &HFF00& 
    Else 'If it returned a 1 we have a closed drawer 
    Label2.Caption = "CLOSED" 
    Shape1.FillColor = &HFF 
    Shape1.BorderColor = &HFF 
    End If 
    End Sub 
    Private Sub Timer1_Timer() 
    Dim Result As Integer 
    Timer1.Enabled = False 'Timer to call the status button every 100 mS 
    Call Status_Button_Click 
    Timer1.Enabled = True 
    End Sub 
    Private Sub GetHandle() 
    If DrawerHandle > 0 Then Exit Sub 'If we have a handle already then exit 
    'Call the "GetDrawerHandle" function 
    DrawerHandle = GetDrawerHandle(DrawerNumber) 
    If DrawerHandle > 0 Then 'If it retured a valid handle set the form 
    Status.Caption = "USB Device Connected" 
    Status.ForeColor = &HFF00& 
    Open_Button.Enabled = True 
    Status_Button.Enabled = True 
    MainForm - 3 
    mnuCashDrawer.Enabled = True 
    Call Status_Button_Click 
    Else 
    Call USBError 'Else we had an error 
    End If 
    End Sub

  2. #2
    Inactif  
    Profil pro
    Inscrit en
    Février 2003
    Messages
    4 341
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2003
    Messages : 4 341
    Par défaut
    Bon je te répond, malgré le manque d'efforts évident de ta part.

    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
    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
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    Global
      DrawerHandle est un entier
      DrawerNumber est un entier court
     
      ngHdlDLL    est un entier
     
    ngHdlDLL = ChargeDLL( "MSPOS_ISB.DLL")
    si ngHdlDLL = 0 alors
      FinProgramme( "impossible de charger la DLL <MSPOS_USB.DLL>")
    fin
     
     
    Procedure DrawerOption_Click(Index est un entier)
     
    DrawerNumber = Index //Get the new drawer ID number
    SI DrawerHandle > 0 ALORS //Check to see if we already have a valid handle
    //If so release the handle call "ReleaseDrawerHandle"
      AppelDLL32( "MSPOS_USB.DLL", "Call ReleaseDrawerHandle",DrawerHandle)
      DrawerHandle = 0 //Reset the handle to 0
    FIN //Si
     
    AppelDLL32( "MSPOS_USB.DLL", "Call Status_Button_Click") //Call the "Get Status" button routine
    //Fin procedure
     
    //Je ne traite pas cette Procedure qui ne fait appel qu''a des elelements de fenêtre
    Procedure Form_Load()
     
    Procedure Form_Terminate()
    //If we have a valid handle then release it
    SI DrawerHandle > 0 Alors
      AppelDLL32( "MSPOS_USB", "ReleaseDrawerHandle", DrawerHandle)
    FIN
    //Fin Procedue
     
    Procedure Form_Unload(Cancel est un entier)
    //If we have a valid handle then release it
    SI DrawerHandle > 0 ALORS 
      AppelDLL32( "MSPOS_USB", "ReleaseDrawerHandle", DrawerHandle)
    FIN
    //Fin procedure
     
    Procedure mnuAbout_Click()
    //Pareil interfacage avec la fenetre
     
     
    Procedure mnuExit_Click()
    //If we have a valid handle then release it
    SI DrawerHandle > 0 Alors AppelDLL32( "MSPOS_USB", "ReleaseDrawerHandle", DrawerHandle)
    //Fin procedure
     
    Procedure Open_Button_Click()
    local
      Result est un entier
     
    GetHandle( ) //Get a handle for the device if we do not have one
    SI DrawerHandle = 0 ALORS RETOUR //If not valid then exit
    Result = AppelDLL32( "MSPOS_USB", "OpenDrawer", DrawerHandle) //Else call "OpenDrawer" function
    //Catch errors on the USB Device
    SI Result = 0 ALORS //If it returned a 0 we had an error
      USBError( )
    Fin
     
    //Fin procedure
     
    Procedure USBError()
    //This gets called when there was a reported error getting or sending data
    //From the USB bus and the device. This sub will set the form porperties to
    //not allow user interaction if the device communication failed.
     
    //INTERFACAGE AVEC L''ECRAN
     
    //Status.Caption = "USB Device NOT Connected!"
    //Status.ForeColor = &HFF
    //Shape1.BorderColor = &H0
    //Shape1.FillColor = &H0
    //Label2.Caption = "OFFLINE"
    //Open_Button.Enabled = False
    //Status_Button.Enabled = False
    //mnuCashDrawer.Enabled = False
     
    AppelDLL32( "MSPOS_USB", "ReleaseDrawerHandle", DrawerHandle)
    DrawerHandle = 0
    //Fin procedure
     
    Procedure Status_Button_Click()
    local
      Result est un entier
     
    GetHandle( )  //Get a handel for teh device if we do not have one
    SI DrawerHandle = 0 ALORS RETOUR //If not valid then exit
    Result = AppelDDL32( "MSPOS_USB", "GetDrawerStatus", DrawerHandle) //Else call "GetDrawerStatus" function
    SI Result = 0 ALORS //If it returned a 0 we had an error
      USBError( )
    SINON 
      SI Result = 2 ALORS //If it returned a 2 we have an open cash drawer
        //INTERFACAGE AVEC LA FENETRE
        Label2.Caption = "OPEN"
        Shape1.FillColor = &HFF00&
        Shape1.BorderColor = &HFF00&
      SINON //If it returned a 1 we have a closed drawer
        //INTERFACAGE AVEC LA FENETRE
        Label2.Caption = "CLOSED"
        Shape1.FillColor = &HFF
        Shape1.BorderColor = &HFF
      FIN
    FIN
    //Fin Procedure 
     
    Procedure Timer1_Timer()
    //Gestion d''un Timer
    //Fin Procedure
     
    Procedure GetHandle()
     
    SI DrawerHandle > 0 ALORS RETOUR //If we have a handle already then exit
    //Call the "GetDrawerHandle" function
    DrawerHandle = AppelDLL32( "MSPOS_USB", "GetDrawerHandle", DrawerNumber)
    SI DrawerHandle > 0 ALORS //If it retured a valid handle set the form
      //INTERFACAGE AVEC LA FENETRE
      Status.Caption = "USB Device Connected"
      Status.ForeColor = &HFF00&
      Open_Button.Enabled = True
      Status_Button.Enabled = True
      MainForm - 3
      mnuCashDrawer.Enabled = True
      Status_Button_Click( ))
    SINON
      USBError( ) //Else we had an error
    FIN
    //Fin procédure

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

Discussions similaires

  1. [VBA-E] Convertir du code VBA 2000 en VBA 97
    Par Mykeul dans le forum Macros et VBA Excel
    Réponses: 2
    Dernier message: 06/04/2006, 12h05
  2. [Free Pascal] Convertir un code ASCII en entier
    Par JoseF dans le forum Free Pascal
    Réponses: 13
    Dernier message: 04/04/2006, 20h30
  3. Convertir du code
    Par K.othmane dans le forum Langage
    Réponses: 4
    Dernier message: 06/02/2006, 17h24
  4. Convertir du code ASM 68020 en C++
    Par )3lade dans le forum Linux
    Réponses: 5
    Dernier message: 13/01/2006, 11h03
  5. [mx2004]Convertir un code ASCII en une lettre
    Par caramel dans le forum Flash
    Réponses: 3
    Dernier message: 28/01/2004, 17h26

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