Click here to Skip to main content
16,005,138 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: How to use Background worker from a form to fill another form? Pin
Suhayb Bashir Yousif22-Sep-13 4:40
Suhayb Bashir Yousif22-Sep-13 4:40 
GeneralRe: How to use Background worker from a form to fill another form? Pin
Richard MacCutchan22-Sep-13 4:51
mveRichard MacCutchan22-Sep-13 4:51 
GeneralRe: How to use Background worker from a form to fill another form? Pin
Suhayb Bashir Yousif22-Sep-13 4:58
Suhayb Bashir Yousif22-Sep-13 4:58 
GeneralRe: How to use Background worker from a form to fill another form? Pin
Richard MacCutchan22-Sep-13 5:09
mveRichard MacCutchan22-Sep-13 5:09 
AnswerRe: How to use Background worker from a form to fill another form? Pin
Eddy Vluggen21-Sep-13 8:44
professionalEddy Vluggen21-Sep-13 8:44 
GeneralRe: How to use Background worker from a form to fill another form? Pin
Suhayb Bashir Yousif22-Sep-13 4:41
Suhayb Bashir Yousif22-Sep-13 4:41 
GeneralRe: How to use Background worker from a form to fill another form? Pin
Dave Kreskowiak22-Sep-13 8:53
mveDave Kreskowiak22-Sep-13 8:53 
Questionthread runs 21 times then exits Pin
Member 1028281518-Sep-13 7:32
Member 1028281518-Sep-13 7:32 
Hi,
I have a vb6 project that has to read the usb port all the time and look at the data to parse it out and put some strings in a file.
The following code will read the usb port and put the data into a circular buffer so that the top level application can read the data and then process it.
This code seems to run 21 times before it just exits.
I do not know what would cause such behavior,
Can anyone offer any suggestions?
Thanks,
Martin

Public Sub WaitForUsbRet()
Dim EventObject As Long
Dim Result As Long
Dim res2 As Integer
Dim Security As SECURITY_ATTRIBUTES
Dim RecBuffer(65) As Byte
Dim rdNum As Long
Dim i As Integer
Dim res3 As Long
res2 = 1

Security.lpSecurityDescriptor = 0
Security.bInheritHandle = CInt(True)
Security.nLength = Len(Security)

EventObject = CreateEvent(Security, CInt(True), CInt(False), "rdUsb")
HIDOverlapped.Offset = 0
HIDOverlapped.OffsetHigh = 0
HIDOverlapped.hEvent = EventObject

Do
Form1.ShpStatus.BackColor = Form1.ShpStatus.BackColor + 1
DoEvents
RecBuffer(4) = 0
RecBuffer(5) = 0
Result = ReadFile _
(HIDHandle, _
RecBuffer(0), _
CLng(Capabilities.InputReportByteLength), _
rdNum, _
HIDOverlapped)

Form1.lstBoxRec.AddItem "Res=" & Result & " rdnum=" & rdNum & " hid=" & HIDOverlapped.Internal

Result = WaitForSingleObject(EventObject, 500)

Form1.lstBoxRec.AddItem "Res2=" & Result & " err=" & GetLastError & " hid=" & HIDOverlapped.Internal

Select Case Result
Case WAIT_TIMEOUT
' Timeout error.
Form1.lstBoxRec.AddItem "Out"
CancelIo (ReadHandle)
Form1.devStatus = RET_USBDEVREVTOOLOW
DoEvents
Case WAIT_FAILED Or WAIT_ABANDONED
Form1.lstBoxRec.AddItem "FAIL"
DoEvents
Case WAIT_OBJECT_0
' ' Success
' ' Use the report data.
rdNum = (RecBuffer(4) + 5)
If rdNum > 65 Then rdNum = 65
If (rdNum > 5) Then
For i = 1 To rdNum
Form1.putInCircBuff (RecBuffer(i))
Next i
End If
Form1.lstBoxRec.ListIndex = Form1.lstBoxRec.ListCount - 1
If (rdNum > 0) Then Form1.tmrCommHndl.Enabled = True
DoEvents
Case Else
Form1.lstBoxRec.AddItem "Else"
CancelIo (ReadHandle)
Form1.devStatus = RET_USBDEVREVTOOLOW
End Select
res3 = ResetEvent(EventObject)
Loop Until res2 = 0
End Sub

Question[Solved] Problem when using multiple projects in a solution - Code is being ignored) Pin
msultana17-Sep-13 16:04
msultana17-Sep-13 16:04 
QuestionRe: Problem when using multiple projects in a solution - Code is being ignored) Pin
Eddy Vluggen18-Sep-13 7:05
professionalEddy Vluggen18-Sep-13 7:05 
AnswerRe: Problem when using multiple projects in a solution - Code is being ignored) Pin
TnTinMn18-Sep-13 9:53
TnTinMn18-Sep-13 9:53 
GeneralRe: Problem when using multiple projects in a solution - Code is being ignored) Pin
msultana22-Sep-13 14:26
msultana22-Sep-13 14:26 
Questionnewbie needs help with creating database application Pin
spsix17-Sep-13 7:04
spsix17-Sep-13 7:04 
AnswerRe: newbie needs help with creating database application Pin
Richard MacCutchan17-Sep-13 7:34
mveRichard MacCutchan17-Sep-13 7:34 
AnswerRe: newbie needs help with creating database application Pin
Mycroft Holmes17-Sep-13 13:09
professionalMycroft Holmes17-Sep-13 13:09 
GeneralRe: newbie needs help with creating database application Pin
GuyThiebaut18-Sep-13 2:49
professionalGuyThiebaut18-Sep-13 2:49 
Questionexecuting linux commands remotely using ssh and storing command output locally using vb script Pin
superselector15-Sep-13 22:53
superselector15-Sep-13 22:53 
AnswerRe: executing linux commands remotely using ssh and storing command output locally using vb script Pin
Eddy Vluggen16-Sep-13 7:08
professionalEddy Vluggen16-Sep-13 7:08 
GeneralRe: executing linux commands remotely using ssh and storing command output locally using vb script Pin
superselector18-Sep-13 22:39
superselector18-Sep-13 22:39 
GeneralRe: executing linux commands remotely using ssh and storing command output locally using vb script Pin
superselector19-Sep-13 21:39
superselector19-Sep-13 21:39 
QuestionRetrieving Custom Attributes on Enumeration Members Pin
Dominick Marciano13-Sep-13 18:01
professionalDominick Marciano13-Sep-13 18:01 
AnswerRe: Retrieving Custom Attributes on Enumeration Members Pin
Eddy Vluggen15-Sep-13 2:18
professionalEddy Vluggen15-Sep-13 2:18 
QuestionVideo overlay and Full Screen Vb 6 Pin
Member 1027147112-Sep-13 23:14
Member 1027147112-Sep-13 23:14 
AnswerRe: Video overlay and Full Screen Vb 6 Pin
Eddy Vluggen15-Sep-13 2:27
professionalEddy Vluggen15-Sep-13 2:27 
QuestionTextbox keeps losing focus Pin
CJotaO12-Sep-13 3:32
CJotaO12-Sep-13 3:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.