Author Topic: Return problems with textbox in windows form  (Read 1414 times)

0 Members and 1 Guest are viewing this topic.

Peter Jamtgaard

  • Guest
Return problems with textbox in windows form
« on: December 07, 2012, 04:28:48 PM »
I have been having a problem with a textbox in a windows form

I would like the user to have the ability to hit a return after entering a string and have the string be evaluated and the response appear below in the same dialog.

No matter what I do it either ignores the return or recognizes the return as an accept and closes the dialog.

Thoughts?

P=

fixo

  • Guest
Re: Return problems with textbox in windows form
« Reply #1 on: December 07, 2012, 04:40:15 PM »
This piece of code from working routine, I use KeyPress event
to drop on to next textbox, i.e.:
Code: [Select]
Private Sub txtRoof_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtRoof.KeyPress
        If Char.IsNumber(e.KeyChar) = False And Microsoft.VisualBasic.AscW(e.KeyChar) <> 46 Then
            If e.KeyChar = CChar(DSep) Then
                e.Handled = True
            ElseIf Microsoft.VisualBasic.AscW(e.KeyChar) = 13 Then
                Me.txtGrunt.Select()'' next box selected, so you can add any text string here
               '' something like
-------------''  Me.txtGrunt.Text=txtRoof.Text  ''-------------------
                e.Handled = False
            Else
                e.Handled = True
            End If
        End If
    End Sub

Peter Jamtgaard

  • Guest
Re: Return problems with textbox in windows form
« Reply #2 on: December 07, 2012, 05:28:59 PM »
This worked.

Thanks...

I was working on my "bullet proof" lisp evaluator for .net

Code - vb.net: [Select]
  1.     Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
  2.         If Char.IsNumber(e.KeyChar) = False And Microsoft.VisualBasic.AscW(e.KeyChar) <> 46 Then
  3.             If Microsoft.VisualBasic.AscW(e.KeyChar) = 13 Then
  4.                 EvaluateTextbox()
  5.             End If
  6.         End If
  7.     End Sub
  8.