dizzy_boy Posted August 4, 2004 Posted August 4, 2004 Does anyone have a clue where the problem is. I have a data entry form with databound textboxes. When I'm in a textbox that contains a datetime value and I press Del key, and then leave this box, the date value just reapears. So there is no way to clear once entered date. On other boxes that contain just text this doesn't happen. I'm using this code to format the date so the user just enters for instance 040804 for 04.08.2004 , but even without this code the value stays in no matter how I clear it. It also doesn't format as a ShortDate string despite: udt = Date.Parse(udt).ToShortDateString Can anyone help me. Private Sub editdatum_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles editdatumu.Leave, editdatumr.Leave, editdatump.Leave Dim udt As String udt = CType(sender, TextBox).Text If udt > "" Then Try If udt.IndexOf(".") = -1 Or udt.IndexOf(",") = -1 Then udt = udt.Insert(2, ".") udt = udt.Insert(5, ".") End If udt = Date.Parse(udt).ToShortDateString CType(sender, TextBox).Text = udt CType(sender, TextBox).BackColor = Color.White Catch ex As System.Exception Dim potvrda As MsgBoxResult potvrda = System.Windows.Forms.MessageBox.Show("Neispravan datum!" & Chr(13) & ex.Message, "", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) If potvrda = MsgBoxResult.OK Then CType(sender, TextBox).BackColor = Color.Yellow CType(sender, TextBox).Focus() CType(sender, TextBox).SelectAll() Else CType(sender, TextBox).BackColor = Color.White End If End Try Else CType(sender, TextBox).BackColor = Color.White End If End Sub Quote
Moderators Robby Posted August 5, 2004 Moderators Posted August 5, 2004 The first thing that stands out is this line... If udt > "" Then Try this instead... If Not udt.Length = 0 Then Also, is the text box bound to a table? Tip: place Option Strict On at the top of all your code pages. Quote Visit...Bassic Software
dizzy_boy Posted August 7, 2004 Author Posted August 7, 2004 The first thing that stands out is this line... If udt > "" Then Try this instead... If Not udt.Length = 0 Then Also, is the text box bound to a table? Tip: place Option Strict On at the top of all your code pages. Sorry, for no reply, but I'm on vaccation for the next 10 days. Yes the textbox is bound to a typed dataset table. I will try your suggestion when I get back, and get back to you with the result. Thanks Quote
Joe Mamma Posted August 7, 2004 Posted August 7, 2004 Vacation? Vacation?!?!? I know not this word. wot means this word? It has such a charming ring to it but its essence eludes me. . . YOU CALL YOURSELF A DEVELOPER?!?!? WE DON'T TAKE NO STINKIN' VACATIONS!!!!! CODE TO LIVE! LIVE TO CODE! EAT DRINK SLEEP F*** CODE!!! 'I am code-holio! I need VB-For my Bunghole!!!' 'Thank you, drive through! Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
dizzy_boy Posted August 16, 2004 Author Posted August 16, 2004 First day after my vaccation, the solution just poped out: I just set CausesValidation Property of the textboxes to false and everything works fine. Who says vaccation is just a vaste of time! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.