Note that there are some explanatory texts on larger screens.

plurals
  1. POChecking text in Rich textbox in vb.net
    text
    copied!<p>I'm using a Rich Textbox in my vb.net application on update form to take address value. My update query is generated at run time looping through the textboxes on the form and checking which fields have got some value and the corresponding fields are updated in the database.</p> <pre><code>For Each x As Control In Me.Controls If x.GetType Is GetType(TextBox) Or x.GetType Is GetType(MaskedTextBox) Or x.GetType Is GetType(RichTextBox) Then If Not x.Name = "party_code" Then 'if user has not entered a value in a textbox then incremnets the flag variable If (x.Text = String.Empty) Or ((x.Name = "contact1" Or x.Name = "contact2" Or x.Name = "ptcl") And (x.Text.Trim().EndsWith("-") And x.Text.Trim().StartsWith("-"))) Then flag += 1 End If 'checks if the user has entered a value in some textbox If (Not x.Text = String.Empty And Not x.Name = "contact1" And Not x.Name = "contact2" And Not x.Name = "ptcl") Or ((x.Name = "contact1" Or x.Name = "contact2" Or x.Name = "ptcl") And Not x.Text.Trim.EndsWith("-")) Then 'generates query text for the textbox which contains some value str = str &amp; comma &amp; x.Name &amp; " = @" &amp; x.Name comma = " , " End If End If End If Next </code></pre> <p>I'm also using Enter key to shift focus to next textbox on the form. When the focus reaches Adress Rich textbox and I don't have to update address field in database and i press Enter key to move to next textbox then the above code tracks that Address Rich Textbox has got some new value i.e. the Enter Key and updates the address field in the database. How can i get rid of this issue??</p> <p>Code behind shifting Focus:</p> <pre><code> Private Sub town_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles town.KeyDown If e.KeyData = Keys.Return Then address.Focus() End If End Sub Private Sub address_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles address.KeyDown If e.KeyData = Keys.Return Then Button3.Focus() End If End Sub </code></pre> <p>I've handled it through Keydown event..!!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload