• 0

How to recognize Chr(13) in textbox ?


Question

  • 0
  Elagizy said:
hi

when i run this code "enter" is recognized ...

If InStr(Text1.Text, Chr(13), CompareMethod.Binary) Then

but this code,  "enter" is not recognized ... WHY ?

If Text1.Text = Chr(13) Then

i need to know how to recognize if Text1.text = chr(13) only or not ?

thanks for any help

585659076[/snapback]

Check the length of the string?

11 answers to this question

Recommended Posts

  • 0
  gameguy said:
For Windows machines, you need to use both characters 13 (carriage return) and 10 (new line).

In fact, it's better off not to use the individual characters at all. Instead, use Environment.NewLine (Y)

585659270[/snapback]

can you tell me the code, pleaaaaaase ?

  • 0
  Elagizy said:
i did it anyway :p, besides i can't understand what do you mean .

585659575[/snapback]

He's talking about using the .NET method System.Environment.NewLine.

It returns the new line based on the current environment, there's no difference right now, but future wise when the framework is ported to another OS, the new line will differe across platforms, it's just better to conform this way earlier, so that your applications would have the possibility of being compatible with other OS's providing that a framework is created for another OS withing the future.

  • 0
  Winston said:
He's talking about using the .NET method System.Environment.NewLine.

It returns the new line based on the current environment, there's no difference right now, but future wise when the framework is ported to another OS, the new line will differe across platforms, it's just better to conform this way earlier, so that your applications would have the possibility of being compatible with other OS's providing that a framework is created for another OS withing the future.

585659936[/snapback]

hmm, ok can you please give me the code which recognize if text1.text = chr(13) using System.Environment.NewLine cause i can't do it

  • 0
  Elagizy said:
hmm, ok can you please give me the code which recognize if text1.text = chr(13) using System.Environment.NewLine cause i can't do it

585659997[/snapback]

Actually an easier way would be using this

    Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
        If e.KeyCode.Enter Then
            MessageBox.Show("Ita carriage return")
        End If
    End Sub

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.