|
AFAIK you need a good USB driver then; and that would be specific to both the peripheral and the operating system (some drivers survive a single major Windows upgrade). I don't think it is up to a customer to create drivers for a manufacturer's hardware, but if you were to go that route: I wish you good luck. And I wouldn't mind reading a CP article when it's done.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Hi!
I have some problems with the BackGroundWorker. The code can make the DoWork fire, but when the DoWork complets the RunWorkerComlpeted do not fire.
What is wrong?
Peter Schwennesen
Public Class Test
Public WithEvents BGW As System.ComponentModel.BackgroundWorker
Private Test As Boolean
Public Function FindAllMachines() As Boolean
Test = False
BGW = New System.ComponentModel.BackgroundWorker
AddHandler BGW.DoWork, AddressOf BGW_DoWork
AddHandler BGW.RunWorkerCompleted, AddressOf BGW_RunWorkerCompleted
BGW.RunWorkerAsync()
System.Threading.Thread.Sleep(30000)
Return Test
End Function
Private Sub BGW_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs)
e.Result = True
End Sub
Private Sub BGW_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs)
Test = True
End Sub
End Class
|
|
|
|
|
I see nothing wrong. Try adding a Console.WriteLine("BGW done") in the completion handler.
BTW: rather than waiting a fixed amount of time, you should use proper synchronization; have a look at AutoResetEvent, and its Set() and WaitOne() methods.
|
|
|
|
|
You do realize that you put your main thread to sleep for 30 seconds, right? In that time, your main thread cannot respond to the Completed event that returns immediately upon execution. So, you're async method is going to return True to the Completed event, but since the main thread is asleep for 30 seconds, nothing will happen until then.
Anyway, your function FindAllMachine should not be returning a value, it should be a Sub. You should be getting that value form the RunWorkerCompleted event. After all, why would you sleep the main thread so it can't respond to mouse events while you're looking for machines??
|
|
|
|
|
Yeah, this is a bad idea. Dave Kreskowiak is right. But if you still want that try following code:
Do
If Not BGW.IsBusy Then
Return True
End If
System.Windows.Forms.Application.DoEvents()
System.Threading.Thread.Sleep(100)
Loop
Use <pre lang="vb"> Visual Basic Code Here.</pre>
modified on Tuesday, January 11, 2011 9:07 AM
|
|
|
|
|
Hello,
I have a problem, I have to include video from a network camera in an application in VB. NET, I purchased the SDK for the camera, brings examples to implement the video but in C#, I translated the code using a translator online , but there are a couple of lines of code that give me error and not know how to solve them
- An error tells me: "Not allowed a reference to the class "..." when your assembly is connected by way NO-PIA"
-other: "The kind of interoperability "..."class can not be embedded. Use the interface of its place"
- "Public ...()Event is an event and not be called directly. Use the RaiseEvent statement to raise an event"
- "The delegate EventHandler requires an expression ...." AddressOf "or a lambda expression as its single argument constructor
Sorry for my bad english, hope you can help me
Thank you
|
|
|
|
|
Hard to tell without seeing the code. Are you sure you have added proper references to the interop assemblies? Also don't use converters as they only work for simple code.
Best wishes,
Navaneeth
|
|
|
|
|
First thank you for answear, well when you say "Are you sure you have added proper references to the interop assemblies?", do you mean add the references in the menu project add references right?, yes I think I have add all references.
well I think I have a problem in translation this line in C# to VB .NET I dont know how make it right
m_device_conector.ConnectResult += New ...videosdk.device.deviceconectorEvents_ConectResultEventHandler(OnConnectResult)
I dont know if I need delegates, addressof or something like that...
can you help me?
thanks
|
|
|
|
|
Denis9999 wrote: I dont know ...
You could look it up in your VB.NET book. Or in MSDN. Or search some of the CP articles.
What you need probably looks like this:
AddHandler m_device_conector.ConnectResult, AddressOf OnConnectResult
|
|
|
|
|
Thanks for answear, I have a problem it appears me
-Not allowed a reference to the class DeviceConnectorClass when your assembly is connected by way NO-PIA
what means that of "NO-PIA"?? How can I solve it??
because this error I can see if it works the solution "addhandler...."
anybody knows how to solve it??
Thank you very much
|
|
|
|
|
NoPia blog posts[^]
have a read of that maybe it can help you?
As barmey as a sack of badgers
Dude, if I knew what I was doing in life, I'd be rich, retired, dating a supermodel and laughing at the rest of you from the sidelines.
|
|
|
|
|
You could try passing it through a .net converter to change from one to the other.
Google will provide you with many choices, some free, some, better ones, at a charge.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC League Table Link
CCC Link[ ^]
|
|
|
|
|
Dave the only problem is that the OP original did this and I think someone else had mentioned that the converters aren't 100% accurate in converting complex pieces of code
As barmey as a sack of badgers
Dude, if I knew what I was doing in life, I'd be rich, retired, dating a supermodel and laughing at the rest of you from the sidelines.
|
|
|
|
|
Of course not, but it is a start.
He will have to go over it, but if he does it block by block it is an achievable task.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC League Table Link
CCC Link[ ^]
|
|
|
|
|
Thank you all for your answears, I have used a converter to translated, but there is an error that I wrote before and I dont know how to solve it. can anyone help me?
|
|
|
|
|
Just curious...
Are you aware what a PIA is?
Have you contacted the vendor of the SDK you purchased to ensure that they even support VB? Sure, you may be able to get it to work, but things can be just different enough to make it tough sometimes and if they are not going to 'support it' then you might be in the hot heat.
|
|
|
|
|
Can anyone help me solve this problem? It give me this error at crypto.close. Any Suggestions?
Try
'checking to make sure the text box isn't null'
If (Decrypt_TextBox.Text = "") Then
MessageBox.Show("Need to put in the file location or select file in grid for decryption")
Else
'declaring string for file'
Dim filename As String
'Getting the file name that is selected'
filename = getFilename()
'Starting to abstract the data from the database'
database.ConnectionString = "Data Source = [name of database].db3;"
database.Open()
Dim command As SQLite.SQLiteCommand
Dim sqlstatement As String
command = database.CreateCommand
'The following will get the bytes of the file'
Dim filesize As Integer
sqlstatement = "SELECT FileSize From [table name] WHERE FileName=@file;"
command.CommandText = sqlstatement
command.Parameters.AddWithValue("@file", filename)
Dim reader As SQLite.SQLiteDataReader
reader = command.ExecuteReader
filesize = reader.GetValue(0)
reader.Close()
MessageBox.Show(filesize)
Dim data(filesize) As Byte
'The following should get the data'
sqlstatement = "SELECT FileData FROM [table name] WHERE FileName=@file;"
command.CommandText = sqlstatement
command.Parameters.AddWithValue("@file", filename)
Dim buf() As Byte
'This gets the file from the database'
reader = command.ExecuteReader
'The following should get the file back to its original form'
buf = reader.GetValue(0)
MessageBox.Show(buf.Length)
'This is go into the Safe and retrieve file'
Dim datawrite As New System.IO.FileStream("filename", IO.FileMode.Open, IO.FileAccess.ReadWrite)
datawrite.SetLength(0)
datawrite.Write(buf, 0, buf.Length)
datawrite.Close()
reader.Close()
Dim fileinput As New System.IO.FileStream("filename", IO.FileMode.Open, IO.FileAccess.ReadWrite)
'specific file output location wiht proper extension'
Dim fileoutput As New System.IO.FileStream(Decrypt_TextBox.Text & "\" & filename, IO.FileMode.OpenOrCreate, IO.FileAccess.Write)
'The next line makes sure that the file is empty'
'Declaring variables for encryption'
Dim buffer(4096) As Byte 'Holds the bytes for processing
Dim BytesProcessed As Double 'running count for bytes that are processed'
Dim filelength As Double = fileinput.Length() 'Length of file coming in where intEnd will be greater than intStart'
Dim bytesinblock As Integer 'current bytes in block'
Dim crypto As CryptoStream
'Declaring crypto service provider'
Dim scRijndael As New System.Security.Cryptography.RijndaelManaged
'setting up progress bars
Encrypt_ProgressBar.Value = 0
Encrypt_ProgressBar.Maximum = 100
crypto = New CryptoStream(fileoutput, scRijndael.CreateDecryptor(key, IV), CryptoStreamMode.Write)
While BytesProcessed < filelength
'reading the file'
bytesinblock = fileinput.Read(buffer, 0, 4096)
'writing the file to cryptoStream'
crypto.Write(buffer, 0, bytesinblock)
'updating bytes processed'
BytesProcessed = BytesProcessed + CLng(bytesinblock)
'equation for updating bytes in block'
Decrypt_ProgressBar.Value = CInt((BytesProcessed / filelength) * 100)
End While
crypto.Close()
fileoutput.Close()
fileinput.Close()
MessageBox.Show("File is done decrypting")
Decrypt_ProgressBar.Step = 0
Decrypt_ProgressBar.Value = 0
Decrypt_TextBox.Text = ""
End If
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
Return 1
|
|
|
|
|
The size of the file is 10 MB.
|
|
|
|
|
What error do you get?
As barmey as a sack of badgers
Dude, if I knew what I was doing in life, I'd be rich, retired, dating a supermodel and laughing at the rest of you from the sidelines.
|
|
|
|
|
I have searched the web and found many interesting code snippets and information on Speech Recognition however i am wanting to write code that will just recognise any sound coming from a microphone. Can anyone provide code or an idea on how to code, so that when any sound is heard in the microphone a procedure is called.
If there is not enough info above to make my question understood then here is an overview of what i wish the final code to do;
People with severe speech difficulties need to practice saying simple sounds of letters for example when you say the letter 'k' in the word 'kitten' its actually (phonetical type speech) "kuh". If i had a program that this person could use it would show the ltter 'k' and they would respond with "kuh" my program would then move to another letter etc. Well fortunately speech recognition on PC's nowadays is extremely sophisticated and i have coded something that actually works and responds to "kuh". This is great BUT for some of the severely speech diasabled people, what actually comes out when they respond is no more than a grunt. So for their intial training any response should call the procedure. This sounds simple enough but strangely i have found more information on actual recognition of words. Any help greatly apprieciated.
|
|
|
|
|
It means that you will have to do the recording part in your code. For each buffer received from the audio system, calculate the sum of squares of the sample values. If it is beyond a threshold, call your procedure.
|
|
|
|
|
Many thanks for a reply - was beginning to think i'd set a 'stinker' !! Ok i understand what you are saying - how do i record sound? I will do some Googling to see what i can find also.
|
|
|
|
|
This snippet of code runs OK on an XP machine. The database is a SQL Compact 3.1 and I am using VS2005
On a customer's Vista machine it causes an error saying that there is no Column 4 - even though there is!
The remed out bit is some diabnostics trying to solve this. The dtblLoc.Columns.Count must be returning 4 instead of 5 on the Vista machine as it responds for 4 columns but crashes on 5
The value of PLACE_COL is 3 and PROV_COL is 4
If bHasData = True Then
'intColumnsFound = dtblLoc.Columns.Count
'If bDiagsMode Then
' sw.WriteLine("-----------------Columns Found--------------------")
' sw.WriteLine(intColumnsFound.ToString)
'End If
If dtblLoc.Rows.Count = 1 Then
'================================================================================
' SINGLE RESULT AREA
'================================================================================
If ListProcessing = True Then
strReturn = dtblLoc.Rows(0).Item(PLACE_COL).ToString & "|" & dtblLoc.Rows(0).Item(PROV_COL).ToString
If bDiagsMode Then
Has anyone come across this kind of error, or got any ideas?
|
|
|
|
|
What is the value of intColumnsFound ?
I must get a clever new signature for 2011.
|
|
|
|
|
On an XP machine it is returning 5 columns and on a Vista machine it is 4 columns even though the database has 5 columns.
|
|
|
|