|
Check my last post again...I made a modification. Also what is the error your getting with the IsNot line. I don't know when IsNot was added but perhaps you should try 'Not txt is txtSender' instead
|
|
|
|
|
this code is not workin man, its flying...
great job...
i am really thankful to ya alot...
now i think i can frealy go for a sleep...
i was tryn differnt logics for this validations from last 10 hours..
feeling gud now..
bubye buddy..
thanks again and gud night.
|
|
|
|
|
there is one more problem in it...
suppose in textbox1 i have filled integer 3
and in textbox2 i have to fill 31, so the moment i press 3 in textbox2 it will show the error that same value...
it wont wait for the 1 to get typed...
|
|
|
|
|
Yup, thats right. I recomend the validation event. Personally I wouldn't validate text in the manner you want as it changes for the very reason you are now experiencing. What you need to do is create a new procedure to handle the validation event. This is the declaration of that procedure.
Private Sub txtBox_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs)
End Sub
You should move the validation code into this procedure. Then you'll need to change the addhandler statement. The event should be validating and the part that goes after addressof should be the name of the procedure ie. txtBox_Validating. The validating event fires just before the focus changes. In the validating event you can use e.cancel = true to prevent focus from leaving the textbox. So if the text isn't validated you can display a message and cancel the change of focus.
One more thing. Use this
If not txt Is txtSender AndAlso txt.Text = txtSender.Text AndAlso txt.Text <> "" Then instead of the current line you have otherwise validation will fail if a textbox is empty because other textbox's are empty. I should have changed that earlier. I forgot to mention it.
|
|
|
|
|
yeah i had done this thing of validating the empty textbox...
but i am affraid this e.cancel = true is not working dude...
i am using VS 2003. i think this code must be valid in 2005.
only this thing is stucked rest everything is running fine....
any other method u might be having...
|
|
|
|
|
Sorry, that's the only event I know of. I've never used 2003 so I'm not aware of the differences but it does work in 2005. If it's not working for you I'm not sure what to do. I think that's still the right place to do the validation however. You'll just have to come up with a workaround. For one, calling a controls focus method will make that control active. So you could do that inside the validating event if validation fails. At least that way you can bring the users attention back to that control.
|
|
|
|
|
no buddy, i have checked every second method which i was knowing, to do this
validation.
i also tried to used gotfocus validation of textbox.but i think every effort went into vein.
as i am using back end also so i tried to validate this through backend validation.
like if the value in the textbox is same then it wont enter in DB and gives an error. But i think this will be the bad logic..
i cant do anything as i am left with this only...
nyways after using your method fully now i am only stuck at this problem, my every second problem is solved by you reagardin this..the only thing left is it shud not validate untill the user moves to other controll.
sending u the code agian jst have alook and check out if something can be done or not....
nyways thanks....
you really helped alot , i'll make sure in future that i could help you in some way and repay you...
Public class form1<br />
Inherits System.Windows.Forms.Form<br />
Private TextBoxCollection As New ArrayList<br />
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
<br />
For Each ctrl As Control In Me.Controls<br />
If TypeOf ctrl Is TextBox Then<br />
TextBoxCollection.Add(DirectCast(ctrl, TextBox))<br />
AddHandler ctrl.TextChanged, AddressOf txtvalidate_validating<br />
'e.cancel = True<br />
End If<br />
Next<br />
<br />
End Sub<br />
Private Sub txtvalidate_validating(ByVal sender As Object, ByVal e As EventArgs)<br />
<br />
Dim txtSender As TextBox = DirectCast(sender, TextBox) <br />
For Each txt As TextBox In TextBoxCollection <br />
If Not txt Is txtSender AndAlso txt.Text = txtSender.Text AndAlso txt.Text <> "" Then<br />
CType(sender, TextBox).Text = CStr(txt.Text)<br />
MsgBox("You have already filled this value")<br />
Exit For<br />
End If<br />
Next<br />
<br />
End Sub<br />
|
|
|
|
|
Okay I see the mistake. Well I assume it's a mistake. Maybe you reverted back to using the TextChanged event because you couldn't get it to work, but I'll assume for the moment you didn't. When you use AddHandler you never changed the event that would be handled.
The following line
AddHandler ctrl.TextChanged, AddressOf txtvalidate_validating
Should be:
AddHandler ctrl.Validating, AddressOf txtvalidate_validating
The portion after Addhandler is the event that gets handled. The portion after addressof is the method that does the handling. In this case we want to handle the validating event which is the change I made above.
e.cancel = true should occur when validation fails. Also you changed the parameters for the txtValidate_Validating procedure. Probably because you were getting errors do to the fact that the event you were trying to handle was the TextChanged event and not the validating event.
The final code should be this:
Public Class Form1<br />
Inherits System.Windows.Forms.Form<br />
Private TextBoxCollection As New ArrayList<br />
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
For Each ctrl As Control In Me.Controls<br />
If TypeOf ctrl Is TextBox Then<br />
TextBoxCollection.Add(DirectCast(ctrl, TextBox))<br />
AddHandler ctrl.Validating, AddressOf txtvalidate_validating<br />
End If<br />
Next<br />
End Sub<br />
<br />
Private Sub txtvalidate_validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs)<br />
Dim txtSender As TextBox = DirectCast(sender, TextBox)<br />
For Each txt As TextBox In TextBoxCollection<br />
If Not txt Is txtSender AndAlso txt.Text = txtSender.Text AndAlso txt.Text <> "" Then<br />
MsgBox("You have already filled this value")<br />
e.Cancel = True<br />
Exit For<br />
End If<br />
Next<br />
End Sub<br />
End Class
If there is a problem with this code it's because of differences in 2003 vs 2005. But this code works perfectly under 2005.
|
|
|
|
|
its ok and fine...
the line in which u have modified should be having validated in place of validating coz controll is validated after the focus is off, like this
still e.cancel is not working and showing the error that cancel is not the member of system.eventarg but its ok...i'll rectify this part through my database, by dissaloving the user to insert blank value..
AddHandler ctrl.Validated,AddressOf txtvalidate_validating<br />
now its working working perfectly...
thanks...
-- modified at 17:14 Friday 16th March, 2007
|
|
|
|
|
The events fire in this order:
LostFocus
Validating
Validated
'Cancel' is not a property of the system.eventarg object which is the object the Validated event recieves. 'Cancel' IS a property of the System.ComponentModel.CancelEventArgs which is the object the Validating event recieves. I don't understand why you think the validation should occur in the validated event. There is no reason the validation shouldn't be done in the validating event and one very good reason why it should be. This reason would be that you can prevent other controls from responding to the user before they have inserted valid data. I'm glad you've got it working though. As long as it works the way you want I see no reason to change it.
|
|
|
|
|
Dear Friends,
I have ckecked list box in the form but it should work as a radio buton. the user can only select one option fom the checked list box.
How can I do it. Please help.
Thanx in advance.
Taher
|
|
|
|
|
then gofor combobox man
why to increase overhead and complexities...
|
|
|
|
|
Hello,
I have created a new insert procedure to insert a new incident record in the typed dataset designer in the datatable. I want to have the incidentID with is auto generated returned.
I have been playing around with the properties of the insert procedure, but can't find any way to return the incidentID number.
The code I have used for inserting is the following
<br />
INSERT INTO Incident (Company, CompanyID, Priority, Status, Subject, AssignedTo) VALUES (@Company,@CompanyID,@Priority,@Status,@Subject,@AssignedTo) SELECT @IncidentID = SCOPE_IDENTITY()<br />
The code for calling the insert is the following:
<br />
Me.TA_Incident_dsComponent_Equipment1.Insert(Me.cboCustomers.Text, Me.cboCustomers.SelectedValue, "Normal", "Not Started", Me.txtSubject.Text, Me.cboAssignIncident.SelectedValue)<br />
Many thanks with any help.
Steve
|
|
|
|
|
Are you using an SQL Server stored procedure and you want the row Id of the newly inserted record to the table?
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
Hi i have intime(08:45) and outtime(20:16)=>24 hours format...,
Now i want to calculate between the time how many hours and minutes like...,
Plz help me,i need that codes.........,
Regards,
Magi
|
|
|
|
|
if you are using VB.NET then try-----------
Dim intime As DateTime<br />
dim outtime as datetime<br />
<br />
Dim tspan As TimeSpan = outtime.Subtract(intime )
hope this will work.
Live life to the fullest
|
|
|
|
|
but how to assign that tspan value in one textbox?
Plz reply..........
Magi
|
|
|
|
|
Hi,
check this[^]
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
|
|
|
|
|
Its really helpfull for me,
thanks lot......,
Magi
|
|
|
|
|
Hi To All
I Need A Function Name (API) Than Can Make User Under Win NT Family. Localy & Remoot(Under Local Area Network).
I Can Make User ON Local Computer But I Want To Make User On Remote Computer; Can Any One Help Me?
Tanks.
Mogtabam
|
|
|
|
|
i have a little problem with my vb codes.After i click this button1 it gives me a result and after i tried again with other checkbox and radiobutton settings it gives the same result again
what should i have to do for reset the result after it shoves to me
my codes:
Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
bos = 0
toplammaliyet = CInt(Ayarlar.TextBox1.Text * forma) + CInt(Ayarlar.TextBox2.Text * forma) + CInt(Ayarlar.TextBox3.Text * forma) + CInt(Ayarlar.TextBox4.Text * forma) + CInt(Ayarlar.TextBox5.Text * forma) + CInt(Ayarlar.TextBox6.Text * forma) + CInt(Ayarlar.TextBox7.Text * forma) + CInt(Ayarlar.TextBox8.Text * forma) + CInt(Ayarlar.TextBox17.Text * baskisayi) + CInt(Ayarlar.TextBox18.Text * baskisayi) + CInt(Ayarlar.TextBox15.Text * baskisayi) + CInt(Ayarlar.TextBox19.Text * baskisayi) + CInt(Ayarlar.TextBox20.Text * baskisayi) + CInt(Ayarlar.TextBox16.Text * baskisayi) + CInt(Ayarlar.TextBox21.Text * baskisayi) + CInt(bandrol * baskisayi) + CInt(ambalaj * baskisayi) + CInt(Ayarlar.cilt.Text * forma) + CInt(nakliye * baskisayi) + CInt(dizgi * forma) + CInt(kapak) + CInt(iccizim) + CInt(ozalit) + CInt(Ayarlar.rcilt.Text) + CInt(baski) + CInt(ressam) + CInt(ctp)
MsgBox("Bu Kitap için toplam Maliyet" + Str(toplammaliyet))
End Sub
|
|
|
|
|
alpdoruk wrote: what should i have to do for reset the result after it shoves to me
If toplammaliyet carries the result, therefore you should set 0 value for it to reset it. Use toplammaliyet as public variable inside the form and when you done with computing, just assign zero value to it.
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
Public toplammaliyet As Integer
Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
bos = 0
toplammaliyet = 0
toplammaliyet = CInt(Ayarlar.TextBox1.Text * forma) + CInt(Ayarlar.TextBox2.Text * forma) + CInt(Ayarlar.TextBox3.Text * forma) + CInt(Ayarlar.TextBox4.Text * forma) + CInt(Ayarlar.TextBox5.Text * forma) + CInt(Ayarlar.TextBox6.Text * forma) + CInt(Ayarlar.TextBox7.Text * forma) + CInt(Ayarlar.TextBox8.Text * forma) + CInt(Ayarlar.TextBox17.Text * baskisayi) + CInt(Ayarlar.TextBox18.Text * baskisayi) + CInt(Ayarlar.TextBox15.Text * baskisayi) + CInt(Ayarlar.TextBox19.Text * baskisayi) + CInt(Ayarlar.TextBox20.Text * baskisayi) + CInt(Ayarlar.TextBox16.Text * baskisayi) + CInt(Ayarlar.TextBox21.Text * baskisayi) + CInt(bandrol * baskisayi) + CInt(ambalaj * baskisayi) + CInt(Ayarlar.cilt.Text * forma) + CInt(nakliye * baskisayi) + CInt(dizgi * forma) + CInt(kapak) + CInt(iccizim) + CInt(ozalit) + CInt(Ayarlar.rcilt.Text) + CInt(baski) + CInt(ressam) + CInt(ctp)
MsgBox("Bu Kitap için toplam Maliyet" + Str(toplammaliyet))
End Sub
so i make it like that but not working
|
|
|
|
|
ok i make it like that and now works..
thank you very much
Public toplammaliyet As Integer
Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
bos = 0
toplammaliyet = CInt(Ayarlar.TextBox1.Text * forma) + CInt(Ayarlar.TextBox2.Text * forma) + CInt(Ayarlar.TextBox3.Text * forma) + CInt(Ayarlar.TextBox4.Text * forma) + CInt(Ayarlar.TextBox5.Text * forma) + CInt(Ayarlar.TextBox6.Text * forma) + CInt(Ayarlar.TextBox7.Text * forma) + CInt(Ayarlar.TextBox8.Text * forma) + CInt(Ayarlar.TextBox17.Text * baskisayi) + CInt(Ayarlar.TextBox18.Text * baskisayi) + CInt(Ayarlar.TextBox15.Text * baskisayi) + CInt(Ayarlar.TextBox19.Text * baskisayi) + CInt(Ayarlar.TextBox20.Text * baskisayi) + CInt(Ayarlar.TextBox16.Text * baskisayi) + CInt(Ayarlar.TextBox21.Text * baskisayi) + CInt(bandrol * baskisayi) + CInt(ambalaj * baskisayi) + CInt(Ayarlar.cilt.Text * forma) + CInt(nakliye * baskisayi) + CInt(dizgi * forma) + CInt(kapak) + CInt(iccizim) + CInt(ozalit) + CInt(Ayarlar.rcilt.Text) + CInt(baski) + CInt(ressam) + CInt(ctp)
MsgBox("Bu Kitap için toplam Maliyet" + Str(toplammaliyet))
toplammaliyet = 0
End Sub
|
|
|
|
|
Why? Is it giving you an error message? if it does, what is the error message. Are you sure the total is not exceeding the limits of INTEGER. You are saying the it is working okay, but your problem was how to reset the toplammaliyet variable and I showed you the way
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|