|
Thank you SHatchard but that code does exactly the same as mine.
The textbox still doesn't validate with an empty string and focus is forced to the control until it validates.
_______________________________________________________________________
http://www.readytogiveup.com/[ ^]
"you can't forget something you never knew..." M. Du Toit
"Watching Migthy Joe Young made me hate my life..................................I want a gorilla!" A. Havemann
|
|
|
|
|
This field is databounded to a DB cloumn of the type Double.
It seems that NULL is not accepted by datasets for Double columns.
Eventhough the default value is DBNull (which .Net accepts) and the AllowDBNull property is set to TRUE (which .Net accepts)
The columns NullValue property can only be set to <throw exception="">, .Net rejects all other selections.
I still don't have a solution but this problem starting to look more like a bug in .Net than and not in my code.
_______________________________________________________________________
http://www.readytogiveup.com/[ ^]
"you can't forget something you never knew..." M. Du Toit
"Watching Migthy Joe Young made me hate my life..................................I want a gorilla!" A. Havemann
|
|
|
|
|
try to replace
--If Me.MyMaskedTextBox.Text = "" Or IsDBNull(Me.MyMaskedTextBox.Text) Then
with
--if isnothing(Me.MyMaskedTextBox.Text) then
or
--if Me.MyMaskedTextBox.Text is nothing then
if it still doesnt work... may i know what vb are you using?
|
|
|
|
|
Thank you for the response!
That doesn't work either, I'm using VB .Net in Visual Studio 2005.
That field is data-binded to a dataset, the column's type is Double.
I think that has something to do with it not allowing Nulls.
Funny thing is, it allows NULLS, just not when you try to enter it with the textbox!
_______________________________________________________________________
http://www.readytogiveup.com/[ ^]
"you can't forget something you never knew..." M. Du Toit
|
|
|
|
|
O.k, I found a work-around for the problem. Posting it here for the sake of anyone having similar problems.
What happens that causes the problem is that VS doesn't allow a control (in my case a textbox) to lose focus if the text inside it doesn't validate. But for numerical textboxes it also doesn't validate empty strings, even if you want the user to be able to add an empty string.
The solution is to set the data source update mode to never, this disables .Net validation on the control, allowing you to do this with custom code.
Me.MyNumericTextBox.DataBindings.DefaultDataSourceUpdateMode = DataSourceUpdateMode.Never
The validating event still fires though, but it's under YOUR control now, so the following code will allow you to force the user to enter either a numerical value, or an EMPTY STRING.
Private Sub MyNumericTextBox_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyNumericTextBox.Validating
If String.IsNullOrEmpty(Me.MyNumericTextBox.Text) OrElse IsNumeric(Me.MyNumericTextBox.Text) Then
MyErrorProvider.SetError(Me.MyNumericTextBox, "") 'Fire or cancel the
'error in whatever way suites you, this simply clears the errorprovider
Else
MyErrorProvider.SetError(Me.MyNumericTextBox, "The value must be numeric") 'Fire or
'cancel the error in whatever way suites you, this sets the error on the errorprovider
Me.MyNumericTextBox.Focus() 'This forces the user to enter the validated
'data before leaving the control
End If
End Sub
Please reply to this post for more information.
_______________________________________________________________________
http://www.readytogiveup.com/[ ^]
"you can't forget something you never knew..." M. Du Toit
|
|
|
|
|
ASP.NET is irrelevant, you're talking about doing this on the server. I'd look at the Visual Studio Tools for Office, they allow you to manipulate office documents in code.
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 )
|
|
|
|
|
Hi,
i have created one seup application for ne of the company now i want to add Image on the shortcut file which will be created after installing the setup.
So,does anyone knoes how to do this???
GIRISH
|
|
|
|
|
You can set the icon in the setup program, you just have to include the icon image in your setup and then reference the icon in the proper places in the setup project. So you will have the extra icon file when you install your application.
Ben
|
|
|
|
|
To include image Icon
Go to Application Folder and add an icon file there,
and give that path to Desktop or Program Files Reference(give it by Right clicking and selecting icon property)
TO add Icon to Add or Remove programs
press F4(properties)of setup project
the first opetion will be the add icon to addorremove programs one
just select ur icon file
It works for me,
Prashanth
|
|
|
|
|
hi,
Thank you very much for your reply.
GIRISH
|
|
|
|
|
"How to pass value of a variable of one form to the next in vb.net" ( suppose i have a text box in form1 and there is some value , now i want to get back it in the form2 ). I think i have made my problem clear to all . Please send me the code - i need that very badly . Please help me .
Check it out .
|
|
|
|
|
A very simple way (although not the best) is to add a module to your project and declare a public variable in it. This variable will be available to all forms in your app.
Public MyPublicVariable as String
Public Class MyForm1<br />
MyPublicVariable = MyTextBoxOnForm1.Text<br />
End Class<br />
<br />
Public Class MyForm2<br />
MyTextBoxOnForm2.Text = MyPublicVariable<br />
End Class
For example
My advice is free, and you may get what you paid for.
|
|
|
|
|
No, that is just plain super nasty.
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 )
|
|
|
|
|
'Declare the form
Dim oFrm as new frmXXX
'Open the form as a dialog and get the result
if FrmXXX.showdialog(me).dialogresult = Ok Then
sText = oFrm.Textbox1.Text
End If
oFrm.Close
Trick is to HIDE the form in the Ok/Cancel buttons
|
|
|
|
|
Yep, that is the better solution
My advice is free, and you may get what you paid for.
|
|
|
|
|
You should never create 'global' variables, if you can avoid it, nor should you ever expose a UI element as public. You should always expose as little as possible, so in this case, expose a property, which is of type string, and have it return or set the Text property of the specific textbox.
Or, if the first form is creating the second, you can force the setting of this property by passing it through the constructor.
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 )
|
|
|
|
|
iam using vb2005 and microsoft access as database
making database application
and i made this code in form1 and i need the same code but there was some different in the fields
and when i typed it in form2 it didn't work i don't know why
plz help me it's very urgent
i will appreciate all ur efforts
thanks
|
|
|
|
|
sorry the code is
GC.Collect()<br />
<br />
cmd.Connection.Close()<br />
<br />
<br />
If cn.State = ConnectionState.Closed Then<br />
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=ehab.mdb"<br />
cn.Open()<br />
<br />
End If<br />
<br />
<br />
cmd.Connection = cn<br />
cmd.CommandType = CommandType.Text<br />
<br />
<br />
<br />
<br />
Dim h As Integer<br />
Dim s As String<br />
s = 0<br />
h = 0<br />
<br />
Dim f1, f2, f3, f4, f5, f6, f7, f8 As String<br />
<br />
f1 = "#" & DateTimePicker1.Value & "#,"<br />
<br />
f2 = "'" & ComboBox1.Text & "',"<br />
<br />
f3 = "'" & ComboBox2.Text & "',"<br />
<br />
f4 = "'" & TextBox1.Text & "',"<br />
<br />
f5 = "'" & TextBox2.Text & "',"<br />
<br />
f6 = "'" & TextBox3.Text & "',"<br />
<br />
f7 = "'" & TextBox4.Text & "',"<br />
<br />
f8 = "'" & Label10.Text & "'"<br />
<br />
s = "insert into sale"<br />
s = s & " (dte,op,nos,cost,coms,nii,npp)values "<br />
<br />
s = s & "(" & f1 & "," & f2 & "," & f3 & "," & f4 & "," & "," & f5 & "," & "," & f6 & "," & "," & f7 & "')"<br />
<br />
cmd.CommandText = s<br />
cmd.ExecuteNonQuery()<br />
MsgBox("Saved succssefuly")
iam sure it's not wrong
he tell me always ( Syntax error in INSERT INTO statement.)
while the same code was waorking in the form1
plz help
|
|
|
|
|
From what I can see the sql statement would read
INSERT INTO Sale (dte,op,nos,cost,coms,nii,npp) VALUES
('xxx','xxx','xxx','xxx','xxx','xxx','xxx',')
The last value is f7 which is followed by a comma, which shouldnt be there since it is the last item in the list. You also have a ' before the bracket which again is not needed and will cause a syntax error.
If you were to put a breakpoint on the line
cmd.CommandText = s
And watch the value of s you would be able to see the SQL so you could check the syntax.
Hope that helps.
Simon
|
|
|
|
|
SHatchard wrote: If you were to put a breakpoint on the line
cmd.CommandText = s
And watch the value of s you would be able to see the SQL so you could check the syntax.
thanks for ur reply
i have made breakpoint to see the values every one have the value that entered in textbox and combobox ....
and i have correct the code as u said but the same error
here is the correction that i wrote
Dim f1, f2, f3, f4, f5, f6, f7, f8 As String<br />
<br />
f1 = "#" & DateTimePicker1.Value & "#,"<br />
<br />
f2 = "'" & ComboBox1.Text & "',"<br />
<br />
f3 = "'" & ComboBox2.Text & "',"<br />
<br />
f4 = "'" & TextBox1.Text & "',"<br />
<br />
f5 = "'" & TextBox2.Text & "',"<br />
<br />
f6 = "'" & TextBox3.Text & "',"<br />
<br />
f7 = "'" & TextBox4.Text & "',"<br />
<br />
f8 = "'" & Label10.Text & "'"<br />
<br />
s = "insert into sale"<br />
s = s & " (dte,op,nos,cost,coms,nii,npp)values "<br />
<br />
s = s & "(" & f1 & "," & f2 & "," & f3 & "," & f4 & "," & "," & f5 & "," & "," & f6 & "," & f7 & "')"<br />
<br />
cmd.CommandText = s<br />
cmd.ExecuteNonQuery()<br />
MsgBox("Saved succssefuly")<br />
<br />
if u have another SOLUTION plz tell me
thanks a lot
|
|
|
|
|
i tried to write this code insted of the other one
s = s & "(" & f1 & f2 & f3 & f4 & f5 & f6 & f7 & ")"<br />
but it didn't work
|
|
|
|
|
You still have a comma after
f7 = "'" & TextBox4.Text & "',"
as I mentioned earlier, and in your command you do not have a parameter after that which is a syntax error.
In the code above you also still have a single quote ' after the last parameter as well. The reason I suggested the breakpoint was so that you could validate the syntax of the SQL statement.
If you are still having problems after looking at that please copy the contents of s at the breakpoint into a message here
|
|
|
|
|
here the code is it write ??
Dim f1, f2, f3, f4, f5, f6, f7, f8 As String<br />
<br />
f1 = "#" & DateTimePicker1.Value & "#,"<br />
<br />
f2 = "'" & ComboBox1.Text & "',"<br />
<br />
f3 = "'" & ComboBox2.Text & "',"<br />
<br />
f4 = "'" & TextBox1.Text & "',"<br />
<br />
f5 = "'" & TextBox2.Text & "',"<br />
<br />
f6 = "'" & TextBox3.Text & "',"<br />
<br />
f7 = "'" & TextBox4.Text & ""<br />
<br />
' f8 = "'" & Label10.Text & "'"<br />
<br />
s = "insert into sale"<br />
s = s & " (dte,op,nos,cost,coms,nii,npp)values "<br />
<br />
' s = s & "(" & f1 & "," & f2 & "," & f3 & "," & f4 & "," & "," & f5 & "," & "," & f6 & "," & f7 & "')"<br />
<br />
s = s & "(" & f1 & f2 & f3 & f4 & f5 & f6 & f7 & ")"<br />
<br />
the error msg is :Syntax error in string in query expression ''12.75)'.
and here the breakpoint :
"insert into sale (dte,op,nos,cost,coms,nii,npp)values (#7/2/2007#,'Mobinil','10','1','13','0.25','12.75)"
|
|
|
|
|
Change
f7 = "'" & TextBox4.Text & ""
to
f7 = "'" & TextBox4.Text & "'"
and it should work fine then, you only needed to remove the comma
|
|
|
|
|
Thanks very very very much it works well
u r helpful
|
|
|
|
|