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