yaniv Posted June 11, 2003 Posted June 11, 2003 i have two problems with my multi text boxes form: 1) how can move from one textbox to another with the "enter" key, and don't just with the "tab"? 2) when i pass the data to the database i do use "trim" to cut off the spaces, but when i get the data in the text box and i want to update it, there is allways "something" in the text box, even if it was empty in the sending. i have to "erase" the blank textbox and then to rewrite. can you make a textbox that gets a empty data to remain empty? it does happend even if i use this: if isdbnull (firstname) = true then firstname = "" and the textbox of firstname is "full" of spaces. thanks in advance yaniv Quote
Leaders dynamic_sysop Posted June 11, 2003 Leaders Posted June 11, 2003 well the answer to your enter key problem is this : Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown If e.KeyCode = 13 Then TextBox2.Focus() End If Quote
iebidan Posted June 11, 2003 Posted June 11, 2003 To get a null value there must be a null value on the database, be sure to assign the null value when you send the query to the DB Q = "INSERT INTO TABLE (COL1, COL2, COL3) VALUES (1,NULL, 'YOUR NAME')" to check a textbox if it has something you can try the following If Trim(textbox1.Text) = "" Then then when you make the select query to the database you will get the null value, here is a more complete example Q = "INSERT INTO TABLE(COL1, COL2, COL3) VALUES (1," If Trim(TextBox1.Text) = "" Then Q = Q & "NULL," Else Q = Q & TextBox1.Text & "," End If Q = Q & "3)" The use of the trim as you said will cut the blank spaces to the left and right of the text, so if your textbox is blanks or with spaces inserted by the user the condition will always result in true, otherwise if the textbox has text will result in false Hope this helps you Quote Fat kids are harder to kidnap
yaniv Posted June 11, 2003 Author Posted June 11, 2003 the two solution worked, but the "dirty" textboxes is still there. I think the problem is because I use right align textboxes (as a Hebrew speaker), I could solve it in my char textboxes. How ever, about my first question, I don't want to make a event handler to each textbox, so I tried that: if e.keycode = 13 then o = me.control. ' control in focus me.control (o+1).focus end if the problem is I don't know how to get the number of control in focus. Quote
*Experts* Volte Posted June 11, 2003 *Experts* Posted June 11, 2003 You can use this code to focus the next control of the form: Me.GetNextControl(Me.ActiveControl, True).Focus()Substitute "True" for "False" to make it go backwards. 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.