Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

  • Leaders
Posted

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

Posted

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

Fat kids are harder to kidnap
Posted

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.

  • *Experts*
Posted
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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...