|
I have a datagrid with a checkbox column. When a user checks a box, leaves the row, re-enters the row and unchecks the box get the following error:
Operator '=' is not defined for type 'DBNull' and type 'Boolean'
The value of the checkbox changes from true or false to DBNull.
How do I avoid this?
Edit/Delete Message
|
|
|
|
|
Without seeing the actual bit of code that is throwing the error, I am guessing that it is the checkbox's CheckedChanged event.
So you might have something like this:
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged<br />
If CheckBox1.Checked = True Then<br />
'something happens here<br />
End If<br />
End Sub
A checkbox control has three states: Checked, Unchecked and Indeterminate.
Simply avoid the = operator, rather use the <> operator:
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged<br />
If CheckBox1.Checked <> False Then<br />
'something happens here<br />
End If<br />
End Sub
Or a little better even (I am not sure whether this works in VB6 though):
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged<br />
If CheckBox1.CheckState = CheckState.Checked Then<br />
'something happens here<br />
End If<br />
End Sub
Otherwise the DBNull error is only thrown by datasets, recordsets, etc. So you might have something like this:
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged<br />
If CheckBox1.Checked = False Then<br />
SomeOtherCheckBox.Checked = DataSet1.Tables(0).Rows(0).Item("SomeOtherBooleanColumnInTheSameTable")<br />
End If<br />
End Sub
In such a case it is wise to use:
If IsDBNull(DataSet1.Tables(0).Rows(0).Item(0)) = False Then<br />
'Something happens here<br />
End If<br />
Good luck,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
Here is the code causing the problem:
Private Sub grdSelect_CellValueChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles grdSelect.CellValueChanged<br />
If Not mtfLoading Then<br />
checkCell = CType(grdSelect.Rows(e.RowIndex).Cells("Select"), DataGridViewCheckBoxCell)<br />
<br />
If checkCell.Value = True Then<br />
Call EnableObjects(True)<br />
Else<br />
Call EnableObjects(False)<br />
End If<br />
End If<br />
End Sub<br />
checkCell.value gets set to DBNull when rechecked whether it was true or false to begin with and whether or not leaving row.
Since this is a DataGridViewCheckBoxCell I can't use .checked, .checkedChanged, or .checkState.
|
|
|
|
|
You can just add a IsDBNull check before you assign checkCell:
Private Sub grdSelect_CellValueChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles grdSelect.CellValueChanged<br />
If Not mtfLoading Then<br />
If IsDBNull(grdSelect.Rows(e.RowIndex).Cells("Select")) Then<br />
checkCell = False 'or True, your choice<br />
else<br />
checkCell = CType(grdSelect.Rows(e.RowIndex).Cells("Select"), DataGridViewCheckBoxCell)<br />
End If<br />
If checkCell.Value = True Then<br />
Call EnableObjects(True)<br />
Else<br />
Call EnableObjects(False)<br />
End If<br />
End If<br />
End Sub
By the way, you could write this same code more efficiently like so:
Private Sub grdSelect_CellValueChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles grdSelect.CellValueChanged<br />
If Not mtfLoading Then<br />
If IsDBNull(grdSelect.Rows(e.RowIndex).Cells("Select")) Then<br />
Call EnableObjects(False) 'Or True, your choice<br />
'Or just do nothing, and simply wait for this event to be triggered again.<br />
else<br />
Call EnableObjects(CType(grdSelect.Rows(e.RowIndex).Cells("Select"), DataGridViewCheckBoxCell))<br />
End If<br />
End If<br />
End Sub
Hope this helps,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
I changed it a little to get it to work for me:
If Not mtfLoading Then<br />
If IsDBNull(grdSelect.Rows(e.RowIndex).Cells("Select").Value) Then<br />
Call EnableObjects(False)<br />
Else<br />
If CType(grdSelect.Rows(e.RowIndex).Cells("Select"), DataGridViewCheckBoxCell).Value = True Then<br />
Call EnableObjects(True)<br />
Else<br />
Call EnableObjects(False)<br />
End If<br />
End If<br />
End If<br />
<br />
Thank you for your help!!
|
|
|
|
|
I'm new at this but I'm trying. The UnLoad Me happens before the Function call talk has completed. How do I make UnLoad Me wait??
frmSpeak [Form]
spkSpeak [DirectSS]
txtText [TextBox]
Function talk()<br />
Open "c:\webster\1\say.txt" For Input As 1<br />
txtText.Text = Input(LOF(1), 1)<br />
Close 1<br />
spkSpeak.AudioReset<br />
spkSpeak.Speak txtText.Text<br />
End Function<br />
<br />
Private Sub Form_Load()<br />
Call talk<br />
'UnLoad Me<br />
End Sub
Robert, still trying
|
|
|
|
|
Repeating the same question doesn't change the answer.
The only way to make it "wait" without getting any kind of status or if the call doesn't block is to put the thread to sleep (VB6 doesn't have a native way of doing this), but that might also sleep the speech object you're using too.
Check into the API Viewer and look for the Sleep function. This will put your code to sleep, but you may not like the results.
Basically, unless the call blocks or there is an alternate method of using the library (I'm not familiar with it), you have to put in a loop that does nothing for an arbitrary amount of time. So, you might run into a situation where the speach finishes quicker than your delay and the user is sitting there waiting for nothing.
|
|
|
|
|
Why don't you use a Main function?
Dim spkSpeak as new YourSpeakControlClass
Sub Main
Open "c:\webster\1\say.txt" For Input As 1
txtText.Text = Input(LOF(1), 1)
Close 1
spkSpeak.AudioReset
spkSpeak.Speak txtText.Text
While IsTalking
DoEvents
End While
End Sub
Hope it helps.
|
|
|
|
|
MohammadAmiry wrote: While IsTalking DoEvents End While
So, where is this IsTalking getting it's value from? Where is it defined?
THe code you've posted won't even compile unless you specify that stuff...
|
|
|
|
|
Dave Kreskowiak wrote: MohammadAmiry wrote:
While IsTalking DoEvents End While
So, where is this IsTalking getting it's value from? Where is it defined?
THe code you've posted won't even compile unless you specify that stuff...
Dave;
Didn't work for me either. I added a timer loop like you said & it works. Like I said, I'm new at this & trying to learn. How do I get more info on vb6 component [DirectSS] ie; flags, voice selection & etc?
By the way, Thanks!
Private Sub Timer2_Timer()<br />
Dim DelayTime As Long<br />
Dim EndTime As Long<br />
<br />
DelayTime = 5 'Set Delay in Seconds.<br />
EndTime = Format(Time, "s") + DelayTime<br />
If EndTime > 59 Then<br />
'Make sure Seconds is Not Greater than 59.<br />
EndTime = EndTime - 59<br />
End If<br />
Do Until Format(Time, "s") = EndTime<br />
'Yields execution so that the operating system can process other events.<br />
DoEvents<br />
Loop<br />
End Sub<br />
<br />
Function stalk()<br />
Open "c:\webster\1\say.txt" For Input As 1<br />
txtText.Text = Input(LOF(1), 1)<br />
Close 1<br />
DirectSS1.AudioReset<br />
DirectSS1.Speak txtText.Text<br />
Timer2_Timer<br />
End Function<br />
<br />
Private Sub Form_Load()<br />
Call stalk<br />
Unload Me<br />
End Sub
Robert, still trying
|
|
|
|
|
It's not a VB6 component. It's a COM-based library that happens to be installed on your machine.
I don't know which version of the Speech Api you have installed, byt this[^] is the starting point for the current 5.3 version. You can get the 5.1 SDK from here[^]. If I read this stuff correctly, the 5.3 API is built into Vista and not available as a seperate download. Well, maybe part of the Platform SDK 6.0...
There has to be a Status on the speech object you have, which you'd have to poll in a loop to see if it's still talking. Or maybe it exposes an event that signals completion. I simply don't know. What reference did you add to your code to get at the DirectSS class??
|
|
|
|
|
Hi,
I designed a report with crystal report 6.0 and connected it to an odbc data source.Please I want to call this crystal report 6.0 report from VB6.
I got confused in creating the application, database,table objects.
And I dont know how to set the logon info from the code.
HOW CAN CREATE A CRYSTAL REPORT 6 AND CALL IT FROM vb6
Please help out.
-- modified at 11:06 Tuesday 11th September, 2007
|
|
|
|
|
How can i reference form2 in project2 from form1 in project1 where project1 and 2 are in the same solution
thanks
|
|
|
|
|
just right click the project1 choose add reference choose tab project and choose project2
then in form1 add imports project1
and then you can just open form2 as if it was in the same project
be aware that once you reference project2 into project1 you can not reference project1 into project2 (or something like that, it's been a long day )
hope this helps
If my help was helpfull let me know, if not let me know why.
The only way we learn is by making mistaks.
|
|
|
|
|
Thanks for ur reply, however this works only with VS2005 and not VS2003. Iam using VS2003. How can i do it in VS2003?
Thanks again
|
|
|
|
|
It's exactly the same. Setting a reference has not changed between the two versions. In 2003, right-click the References folder and click Add Reference. In the dialog that shows up, click on the Projects tab. The rest should be obvious.
|
|
|
|
|
Hello Friends,
We have Created setup of my project , when we try to install then it work proper but if we run setup on another machine it give error.
//Error
Unable to locate application file 'DemoProject.msi'.
See the setup log file located at 'C:\DOCUME~1\atique\LOCALS~1\Temp\VSD3.tmp\install.log' for more information.
manu
|
|
|
|
|
hi manuo5
IF you deploy your application in your clients machine , you should first check if .NEt frameworks is installed, and not just .NEt framework , but the correct version. its difficult for me to help you , because you posted half information.
What version of VS did you use for your Project?
What RDBMS did you use for your Project.
Note that if you try to install your project from a network share, you will have problem with .NEt Security Issues.
Please elaborate when you post on this Forums or you will be ignored
chess
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sudden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
|
|
|
|
|
The good news is that even if the client does not have the correct .Net framework you can still deploy an application.
If the client is missing the framework it is automatically, with the users permission, downloaded at installation time.
You always pass failure on the way to success.
|
|
|
|
|
I'm guessing that you did not include the msi and exe files for the setup.
Both of these need including - the msi file contains information of how to install the application, for Windows, and needs to be included in your deployments.
I could be completely wrong here - I'l find out soon enough...
Hope this helps
You always pass failure on the way to success.
|
|
|
|
|
any one remind me how to update,delete on asp.net based on given txtfield?
e.g we write code like this in oracle:
--update code:
update EMP set f_name=:txt_name
where id=:txt_id;
commit;
---delete code:
delete from EMP
where id=:txt_id;
commit;
yesser
|
|
|
|
|
That is SQL. So, google on how to execute SQL for Oracle in .NET
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
The program code doesn't come out as supposed to be, the compilation is using the old code and form, not the updated one. For example, even if I add a new button on the form, it comes out without that new button. I can't find out what goes wrong at the compilation. Could anyone tell me about this, please?
Thank You. Ryan
|
|
|
|
|
The errors tab will show you the errors. That the program runs the last good version isn't the most idiotic thing about VS2005, but it's up there.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Try rebuilding the project so that it links all the modules, forms etc again.
It sounds like your new changes have either not been compiled or not been linked again.
You always pass failure on the way to success.
|
|
|
|